lablup / lablup/backend.ai

Improve GraphQL Schema (feat. Relay)

Open
#1,286 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
17h 7m
Merged PRs (30d)
358

Description

### Main idea

Improve the GraphQL schema to be robust, enabling fast frontend development. It should support the Relay Specification by default, ensuring proper operation in a client environment using React and Relay. The following subtasks exist, with higher priority tasks listed at the top:

```Java
### Baseline tasks
- [x] Mutations can return all of the objects and fields that were modified.
- [x] Support the `Node` interface and `node(id:ID!)` query (global ID). ([graphene](https://docs.graphene-python.org/en/latest/relay/nodes/))
- [x] Support Connection: edge, cursor, and pageInfo. ([graphene](https://docs.graphene-python.org/en/latest/relay/connection/))
- [ ] Replace `filter` and `order` arguments to customized Input type arguments
```

### Example of the schema:

```graphql
input CustomerWhereInput {
author: UserRelationWhereInput
createdAt: DateWhereInput
description: StringWhereInput
id: IdWhereInput
OR: [CustomerWhereInput!]
AND: [CustomerWhereInput!]
NOR: [CustomerWhereInput!]
}

input StringWhereInput {
equalTo: String
notEqualTo: String
lessThan: String
lessThanOrEqualTo: String
greaterThan: String
greaterThanOrEqualTo: String
in: [String]
notIn: [String]
exists: Boolean
matchesRegex: String
options: String
text: TextInput
inQueryKey: SelectInput
notInQueryKey: SelectInput
}

enum CustomerOrder {
author_ASC
author_DESC
createdAt_ASC
createdAt_DESC
description_ASC
description_DESC
name_ASC
name_DESC
updatedAt_ASC
updatedAt_DESC
id_ASC
id_DESC
}

customers(
"These are the conditions that the objects need to match in order to be found."
where: CustomerWhereInput,
"The fields to be used when sorting the data fetched."
order: [CustomerOrder!],
"This is the number of objects that must be skipped to return."
skip: Int,
"Returns the items in the list that come after the specified cursor."
after: String,
"Returns the first n items from the list."
first: Int,
"Returns the items in the list that come before the specified cursor."
before: String,
"Returns the last n items from the list."
last: Int,
"The read options for the query to be executed."
options: ReadOptionsInput
): CustomerConnection!

type CustomerConnection {
"Information to aid in pagination."
pageInfo: PageInfo!
"A list of edges."
edges: [CustomerEdge]
"This is the total matched objecs count that is returned when the count flag is set."
count: Int!
}

type Query {
node(
"The ID of an object"
id: ID!
): Node

customers(
"These are the conditions that the objects need to match in order to be found."
where: CustomerWhereInput,
"The fields to be used when sorting the data fetched."
order: [CustomerOrder!],
"This is the number of objects that must be skipped to return."
skip: Int,
"Returns the items in the list that come after the specified cursor."
after: String,
"Returns the first n items from the list."
first: Int,
"Returns the items in the list that come before the specified cursor."
before: String,
"Returns the last n items from the list."
last: Int,
"The read options for the query to be executed."
options: ReadOptionsInput
): CustomerConnection!
}
# ...
```

### Alternative ideas

_No response_

### Anything else?

_No response_

JIRA Issue: BA-207

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.