Connections
Connections provide the one-to-many links between entities in the system, and allow for filtering and paging of the contents of the connection.
For example an Account can have many Contacts, so the Account type has a field called contacts which provides a connection to the Contacts belonging to the Account.
This can be queried with the following snippet:
Example
query {
accounts(filters: [], first: 1) {
edges {
node {
id
name
contacts(filters: []) {
edges {
node {
id
firstName
lastName
}
}
}
}
}
}
}
Pagination
When there are a large number of records in a connection they will be paginated, you can limit the number of records returned with first, and find the total number of records by requesting the pageInfo record.
Note: The default pagination limit is 50, and there is max pagination limit of 100 records. If you request more than that you will only get a max of 100 records back.
Example
query {
resources(filters: [], first: 10) {
pageInfo {
totalRecords
hasNextPage
}
edges {
node {
name
}
}
}
}
an offset can they be specified to jump to a set position in the list
Example
query {
resources(filters: [], first: 10, offset: 10) {
pageInfo {
totalRecords
hasNextPage
}
edges {
node {
name
}
}
}
}
Cursors
Alternatively, you can use the result cursor to request the nextPage of results if you do not want to skip pages.
Example
query {
accounts(filters: [], first: 1) {
edges {
cursor
node {
id
name
}
}
}
}
the edges field will then contain a cursor:
{
"errors": [],
"data": {
"accounts": {
"edges": [
{
"cursor": "Q3Vyc29yOjA=",
"node": {
"id": "T3JnYW5pc2F0aW9uOjIyNDIw",
"name": "Acme Corp"
}
}
]
}
}
}
which can then be used to request the next record:
Example
query {
accounts(filters: [], first: 1, after: "Q3Vyc29yOjA=") {
edges {
cursor
node {
id
name
}
}
}
}
resulting in:
{
"errors": [],
"data": {
"accounts": {
"edges": [
{
"cursor": "Q3Vyc29yOjE=",
"node": {
"id": "T3JnYW5pc2F0aW9uOjI0NDU3",
"name": "Example Client Ltd"
}
}
]
}
}
}