Skip to main content

Parameters

string
required
A GraphQL query string.
If you’re using TypeScript and [default] import this value from a .graphql or .gql file, the variables and return value will be strongly typed.Read more.
Record<string, any>
The named variables your query accepts. If your query has no variables, you needn’t pass any.

Returns

Promise<Record<string, any>>
A Promise to the structured JSON as defined by your query.

Example

To run multiple GraphQL queries in parallel, use runQuery() together with useAsyncCache(). Each call to runQuery() in the cache definition runs in parallel, and the component suspends until all have completed: