Interface GraphQLRequest<Data, Variables>

A GraphQL request representing a single execution in GraphQL.

Remarks

A GraphQLRequest is a single executable request that may be used by a cache or a GraphQL API to deliver a result. A request contains a DocumentNode for the query document of a GraphQL operation and the variables for the given request.

A unique key is generated to identify the request internally by urql. Two requests with the same query and variables will share the same key.

The Data and Variables generics may be provided by a TypedDocumentNode, adding TypeScript types for what the result shape and variables shape are.

See

https://spec.graphql.org/October2021/#sec-Executing-Requests for more information on GraphQL reuqests.

Type Parameters

Hierarchy

Properties

extensions?: RequestExtensions

Additional metadata that a GraphQL API may accept for spec extensions.

See

https://github.com/graphql/graphql-over-http/blob/1928447/spec/GraphQLOverHTTP.md#request-parameters for the GraphQL over HTTP spec

key: number

Unique identifier for the GraphQLRequest.

Remarks

This is a key that combines the unique key of the query and the variables into a unique key for the GraphQLRequest. Any request with the same query and variables will have a unique key by which results and requests can be identified as identical.

Internally, a stable, cached key is generated for the DocumentNode and for the variables and both will be combined into a combined key which is set here, based on a DJB2 hash,

The variables will change the key even if they contain a non-JSON reference. If you pass a custom class instance to variables that doesn't contain a toString or toJSON method, a stable but random identifier will replace this class to generate a key.

query: DocumentNode | TypedDocumentNode<Data, Variables>

A GraphQL document to execute against a cache or API.

Remarks

A GraphQLRequest is executed against an operation in a GraphQL document. In urql, we expect a document to only contain a single operation that is executed rather than multiple ones by convention.

variables: Variables

Variables used to execute the query document.

Remarks

The variables, based either on the AnyVariables type or the TypedDocumentNode's provided generic, are sent to the GraphQL API to execute a request.

Generated using TypeDoc