GraphQL queries
You can query the instances with GraphQL. The query capabilities of the GraphQL API interface represent a subset of the capabilities available from the DMS query endpoints.
A query has these key sections:
-
A query intent
query MyQueryName {
(or just{
as shorthand). -
The query to run. This can be one of four types of queries (with an optional alias, for example,
myAlias: listActor
):-
list<type>
, for example,listActor
lists based on filter parameters. -
get<type>ById
, for example,getActorById
lists based on filter parameters. -
search<type>
, for example,searchActor
searches based on a query parameter. -
aggregate<type>
, for example,aggregateActor
aggregates (count, average etc.) based on a field.See the query types section for more details.
-
-
The query parameters. For example,
filter: {...}
orlimit: 1000
. -
The properties to return at a specified depth.
GraphQL example
query myQuery {
listCountry {
items {
name
demographics {
populationSize
growthRate
}
deaths {
datapoints(limit: 100) {
timestamp
value
}
}
}
nextCursor
}
listDemographics(
filter: {
_and: [{ populationSize: { gte: 2 } }, { populationSize: { lte: 10 } }]
}
) {
items {
populationSize
growthRate
metadata {
key
value
}
}
}
}
Where:
myQuery
declares the query intent.listCountry
andlistDemographics
are the queries to run.- The parameters are
Country
:100
for thedeaths
time series data points, and theDemographics
: filter ofpopulationSize
between 2 and 10. - The properties to return, for
Country
:items
->name
,demographic
->populationSize
,growthRate
, etc.
For more information, see the GraphQL documentation.
Query types
list
queries
list<type>
lets you filter and sort data quickly. For list<type>
you can use these
properties and parameters:
-
Properties
items
: specify the properties to return data forpageInfo
: details about the current set of returned items. The existence ofendCursor
indicates that there is another page of data.
-
Parameters
filter
: the filter you want to use based on theproperties
in your graph. You can useand
,or
, andnot
operators to create complex queries.sort
: the ordering of the returned data you want. Specify an array of one or moreproperties
to sort the data of, and whether their data should be sorted inASC
orDESC
order.after
: where in the result set to continue from, using theendCursor
value from the previous query.first
: the maximum number of items to return. To fetch more items use a new query, and supply the value from the previous query'sendCursor
parameter. (Default maximum: 1000 instances)
Pagination
Pagination is only supported at the top level when using list<type>
queries.
For a query like the one below, cursors will only be returned to paginate through the data returned from Movies
, but not from Actors
. If you need to paginate through nested types, for actors
in this example, use the get<type>ById
queries instead:
query ListMovies {
listMovie {
items {
title
actors {
name
}
}
pageInfo {
endCursor
}
}
}