Relay API Reference - Query / Subscription
query / subscription syntax
query|subscription [<op-name>] {
connection-object [([argument])]{
connection-object-fields
}
}
| Key | Required | Schema | Description |
|---|---|---|---|
| op-name | false | Value | Name query/subscription for observability |
| connection-object | true | ConnectionObject | Name of the table connection |
| argument | false | Argument | One or more filter criteria, instructions for sorting order or pagination |
Example: Relay Query
query {
author_connection(first: 2) {
pageInfo {
hasNextPage
endCursor
}
edges {
cursor
node {
id
name
username
}
}
}
}
Example: Relay Subscription
subscription {
author_connection(first: 2){
pageInfo {
hasNextPage
endCursor
}
edges {
cursor
node {
id
name
username
}
}
}
}q
Note
For details of usage, please see this page.
Syntax definitions
ConnectionObject
connection-object {
pageInfo: {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
edges: {
cursor
node: {
id
field1
field2
json_field[(path: String)]
..
nested object1
nested object2
aggregate nested object1
..
}
}
}
| Field | Type |
|---|---|
| pageInfo | PageInfo! |
| edges | [Edge!]! |
Note
For more details on the Relay connection object type, refer to the
Relay docs.
PageInfo
Information useful for pagination.
type PageInfo {
hasNextPage: Boolean!
hasPreviousPage: Boolean!
startCursor: String!
endCursor: String!
}
Note
For more details on the Relay PageInfo object type, refer to the
Relay docs.
Edge
Edge is an object type that consists of a cursor and node fields. node is a table object type which
implements the Relay Node interface.
type tableEdge {
cursor: String!
node: table!
}
Cursor
The cursor field returns a unique non-null String value which is useful for pagination.
Note
For more details on the Relay cursor, refer to the Relay docs.
Argument
DistinctOnExp
Same as the generic DistinctOnExp
WhereExp
Same as the generic WhereExp
OrderByExp
Same as the generic OrderByExp
PaginationExp
Forward Pagination:
first: Integer
[after: Cursor]query {
article_connection(first: 2, after: "eyJpZCIgOiAzfQ==") {
pageInfo {
startCursor
endCursor
hasPreviousPage
hasNextPage
}
edges {
cursor
node {
title
content
author_id
}
}
}
}
Backward Pagination:
[last: Integer]
[before: Cursor]query {
article_connection(last: 2, before: "eyJpZCIgOiA0fQ==") {
pageInfo {
startCursor
endCursor
hasPreviousPage
hasNextPage
}
edges {
cursor
node {
title
content
author_id
}
}
}
}