Skip to main content

GraphQL query language specifications

Data querying specifications

You can query the template instances with GraphQL. A query has these key sections:

  • A query intent (query MyQueryName {, or just { as a shorthand.

  • The query to run. For templates, this is one of 3 types of query (with an optional alias, for example myAlias: listActor):

    • list<type>, for example listActor 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 below for more details.

  • The query parameters. For example filter: {...} or limit: 1000.

  • The properties to return at a specified depth.

GraphQL example

query myQuery {
countryQuery {
items {
name
demographics {
populationSize
growthRate
}
deaths {
datapoints(limit: 100) {
timestamp
value
}
}
}
nextCursor
}
demographicsQuery(
filter: {
_and: [{ populationSize: { gte: 2 } }, { populationSize: { lte: 10 } }]
}
) {
items {
populationSize
growthRate
metadata {
key
value
}
}
}
}

Where:

  • myQuery - declares the query intent.
  • countryQuery and demographicsQuery - are the queries to run.
  • The parameters are Country:100 for the death time series data points, and the Demographics: filter of populationSize 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> enables you to filter and sort data quickly. For list<type> you can use these properties and parameters:

  • Properties

    • items - Specify which properties to be returned.
    • pageInfo - Details about the current set of items that is returned, such as hasPreviousPage and hasNextPage if there is a startCursor or endCursor,.
  • Parameters

    • filter - The filter you want to provide. This is based on the properties in your data model and you can do array of and, or and not to make more complex queries.
    • sort - The sorting you want to provide. To specify an array of properties and if they are sorted in ASC or DESC order.
    • after - The nextCursor from the previous query.
    • first - The maximum number of items to return. To fetch more items, use a anew query using the endCursor parameter (Default: 1000).

search queries

search<type> enables you to search and query data quickly. For search<type> you can use these properties and parameters:

  • Properties - The same as for the list queries.

  • Parameters

    • filter - The filter you want to provide. This is based on the properties in your data model and you can do array of and, or, and not to make more complex queries.
    • properties - The properties you want to search on. This can be an array of properties.
    • query - The actual search queries. Wildcards are supported.
    • first - The maximum number of items to return. To fetch more items, use a anew query using the endCursor parameter (Default: 1000)

aggregate queries

aggregate<type> enables you to aggregate data quickly. For aggregate<type> you can use these properties and parameters:

  • Properties

    • group - Depending on the groupBy parameter, this indicates the group.
    • avg - For number properties, you can ask for the average.
    • count - For any type of properties, you can ask for the total count.
    • histogram(interval: <number>) - For number properties, you can ask for the histogram at the given interval.
    • max - For number properties, you can ask for the maximum value.
    • min - For number properties, you can ask for the minimum value.
    • sum - For number properties, you can ask for the total sum.
    • pageInfo - The details about the current set of items that is returned, such as hasPreviousPage and hasNextPage to allong if there is a startCursor or endCursor.
  • Parameters

    • filter - The filter you want to provide. This is based on the properties in your data model and you can do array of and, or, and not to make more complex queries.
    • properties - The properties you want to search. This can be an array of properties.
    • query - The actual search queries. Wildcards are supported.
    • groupBy - The field to group by (no relationship allowed),
    • after - The nextCursor from the previous query.

Filter specifications

FieldFilterHow to use
Top level filtersAnyand{and: [{...},{...}]} = if everything is true.
or{or: [{...},{...}]} = if at least one is true.
not{not: {...}} = if false.
PrimitivesAnyeq{eq: ...}
in{in: ["..."]} = if any of term.
NullableisNull{isNull: True} = if the field is empty.
Stringprefix{prefix: "..."} = starts with.
Int/Int64/Float/Timestamplt{lt: ...} = less than.
gt{gt: ...} = greater than.
lte{lte: ...} = less than or equals.
gte{gte: ...} = greater than or equals.
TimeSeriesNone supported.
User Defined TypeNone supported.
Lists([XXX])None supported.