-
Notifications
You must be signed in to change notification settings - Fork 657
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Pagination] Support nodes in Connection types (#5754)
* Support nodes in Connection types * Add a reference to the Relay spec issue about nodes
- Loading branch information
Showing
11 changed files
with
427 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
tests/pagination/src/commonMain/graphql/pagination/connectionWithNodes/extra.graphqls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
extend schema @link(url: "https://specs.apollo.dev/kotlin_labs/v0.2", import: ["@typePolicy", "@fieldPolicy"]) | ||
|
||
extend type Query @typePolicy(connectionFields: "users") | ||
|
||
extend type User @typePolicy(keyFields: "id") |
13 changes: 13 additions & 0 deletions
13
tests/pagination/src/commonMain/graphql/pagination/connectionWithNodes/operations.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
query Users($first: Int, $after: String, $last: Int, $before: String) { | ||
users(first: $first, after: $after, last: $last, before: $before) { | ||
pageInfo { | ||
startCursor | ||
endCursor | ||
} | ||
nodes { | ||
id | ||
name | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
tests/pagination/src/commonMain/graphql/pagination/connectionWithNodes/schema.graphqls
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
type Query { | ||
users(first: Int = 10, after: String = null, last: Int = null, before: String = null): UserConnection! | ||
} | ||
|
||
# In this schema, Connection types have a `nodes` field in addition to the `edges` field. | ||
# This can simplify accessing the data. The GitHub API uses this pattern for example. | ||
# See [this issue on the Relay spec](https://github.com/facebook/relay/issues/3850) that discusses this. | ||
type UserConnection { | ||
pageInfo: PageInfo! | ||
edges: [UserEdge!]! | ||
nodes: [User!]! | ||
} | ||
|
||
type PageInfo { | ||
hasNextPage: Boolean! | ||
hasPreviousPage: Boolean! | ||
startCursor: String | ||
endCursor: String | ||
} | ||
|
||
type UserEdge { | ||
cursor: String! | ||
node: User! | ||
} | ||
|
||
type User { | ||
id: ID! | ||
name: String! | ||
email: String! | ||
admin: Boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.