GraphQL Query Parameters

The GraphQL query() method in the Data SDK includes several parameters.

Runs a GraphQL query with reactive capabilities.

ParameterTypeDescription
querystringThe GraphQL query operation string, which accepts an inline gql template tag or an external .graphql file.
variables?V, defaults to Record<string, unknown>Optional key-value map of GraphQL variables referenced by the query.
operationName?stringOptional operation name for multi-operation documents.
cacheControl?CacheControlOptional cache control settings for the GraphQL request.

All GraphQL queries follow this UI API structure.

For more information, see Query Objects in the GraphQL API Developer Guide.

The return type of dataSdk.graphql?.query(), which resolves to the typed GraphQL response payload.

GraphQL record queries return this response structure.

Query results from graphql.query() are reactive and support real-time updates through subscriptions, which you can use to update your UI automatically when data changes.

The subscribe() method listens for updates to a query result. Subscribers are notified when the data changes due to cache updates or explicit refreshes.

Use the refresh() method to manually re-fetch data, bypassing the cache.

Here’s an example on how to query records. The example uses the useState and useEffect React hooks to manage the component state and respond to data changes.

For more examples, see the Multi-framework recipes repo.

A successful query response includes record data in the node object.

A partially successful query response includes errors and some data.