/graphql endpoint of the
REST (JSON) API.
See GraphQL API reference for the list of supported
requests and parameters.
Configuration
GraphQL API is enabled by default and secured using API scopes and CORS. To disallow access to GraphQL API, disable thegraphql
scope, e.g., by setting the CUBEJS_DEFAULT_API_SCOPES environment variable to
meta,data.
The GraphQL schema is built for each caller from the members that
access policies make visible to them. Hidden members are absent from
introspection, and querying one fails GraphQL validation with a
Cannot query field "<member>" error (HTTP 400, no data). If no members are
visible at all, the schema contains only the
no_queries_available field.
To find your GraphQL API endpoint in Cube Cloud, go to the Status
page, click API credentials, and choose the GraphQL API tab.
Getting started
As an example, let’s use theorders cube from the example eCommerce database:
Modifying time dimension granularity
The granularity for a time dimension can easily be changed by specifying it in the query:value:
Specifying filters and ranges
Filters can be set on the load query or on a specific cube. Specifying the filter on the load query applies it to all cubes in the query. Filters can be added to the query as follows:numbervalues are used for number types instead of strings- The
notSetfilter is replaced by{ set: false } - New
inandnotInfilters to check for multiple values ANDandORfields for boolean operators
@skip and @include directives too:
Querying multiple cubes
Using the sameorders cube as before, let’s try and get the numbers of
products for each order status too. We can do this by adding the products cube
to our query as follows: