Query Examples
Basic Query
Select customers displayname from all contracts:
Basic Query by Id
Select a customers displayname from a specific contract based on Id:
query testQueryContractsCustomer
{
contractById (id: "daf2a431f1834cd7942693854a74bf15") {
customers {
customer {
displayName
}
}
}
}
Basic Query by Multiple Id's
Select customers displayName from one or more contracts based on a list of Id's:
query testQueryContractsCustomer
{
contractsById (ids:["daf2a431f1834cd7942693854a74bf15", "72d5a78eb6234156811d35a17e4a18d3"]) {
customers {
customer {
displayName
}
}
}
}
Filtering
Select contracts where customers displayName contains "John":
query testQueryContractsCustomer
{
contracts (where: {customers: {all: {customer: {displayName: {contains : "John"}}}} }){
nodes {
id
customers {
customer {
displayName
}
}
}
}
}
Input Paramteters
Select customers displayname from all contracts with input parameters to include contracts that has expired. Other examples of input parameters are includeFuture, includeDraft, includeRemoved and includeTemporary:
query testQueryContractsCustomer
{
contracts (includeExpired: true){
nodes {
id
customers {
customer {
displayName
}
}
}
}
}
Cursor Pagination
⚠ This is currently being translated to the database as offset pagination rather than a valid cursor pagination query. A widened version of cursor pagination will be supported in the near future!
👉 If you want to use an alternative cursor pagination method which uses real cursor pagination, please head to our SyncQuery example at the end of the page (testQueryPaginationKeyset).
Why Use SyncQueries?
For clients retrieving substantial data sets, we recommend leveraging our SyncQueries. Unlike the regular query method, SyncQueries do not apply default filtering, such as excluding removed rows, and instead implement true cursor pagination. The examples below illustrate how to make use of this feature.
Default Sorting and Cursor Pagination
Every query will have an default sorting with an unique identifier if no specific Order
has been applied by the client.
Note: Make sure to use Order
with an unique identifier when using cursour pagination, otherwise the result between pages will vary and the operation loses its purpose.
More information about pagination
Example Queries with pagination
query queryPagination
{
contracts (first: 5) {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
nodes {
id
customers {
customer {
displayName
}
}
}
}
}
query queryPaginationCursor
{
contracts (first: 5, after: "NQ==", order: {id:ASC}) {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
nodes {
id
customers {
customer {
displayName
}
}
}
}
}
lastId
: Should be set to the latest fetched id. To fetch the first page, simply leave lastId
as null
.