Interface OperationResult<Data, Variables>

A result for an Operation carrying a full GraphQL response.

Remarks

An OperationResult is the result of an Operation and carry a description of the full response on them. The operation is set to the Operation that this result fulfils.

Unlike ExecutionResult, an OperationResult will never be an incremental result and will always match the fully merged type of a GraphQL request. It essentially is a postprocessed version of a GraphQL API response.

Type Parameters

Hierarchy

  • OperationResult

Properties

data?: Data

The result of the execution of the GraphQL operation.

See

https://spec.graphql.org/October2021/#sec-Data for the GraphQL Data Response spec

Contains a description of errors raised by GraphQL fields or the request itself by the API.

Remarks

The error of an OperationResult is set to a CombinedError if the GraphQL API response contained any GraphQL errors.

GraphQL errors occur when either a GraphQL request was prevented from executing entirely (at which point data: undefined is set) or when one or more fields of a GraphQL request failed to execute. Due to the latter, you may receive partial data when a GraphQL request partially failed.

extensions?: Record<string, any>

Additional metadata that a GraphQL API may choose to send that is out of spec.

See

https://spec.graphql.org/October2021/#sel-EAPHJCAACCoGu9J for the GraphQL Response spec

hasNext: boolean

Indicates that the GraphQL response is streamed and updated results will follow.

Remarks

Due to incremental delivery, an API may deliver multiple ExecutionResult | ExecutionResults for a single GraphQL request. This can happen for @defer, @stream, or @live queries, which allow an API to update an initial GraphQL response over time, like a subscription.

For GraphQL subscriptions, this flag will always be set to true.

operation: Operation<Data, Variables>

The Operation which this OperationResult is for.

Remarks

The operation property is set to the Operation that this result is. At the time the OperationResult is constructed (either from the cache or an API response) the original Operation that the exchange delivering this result has received will be added.

The Client uses this to identify which Operation this OperationResult is for and to filter and deliver this result to the right place and consumers.

stale: boolean

Indicates that an OperationResult is not fresh and a new result will follow.

Remarks

The stale flag indicates whether a result is expected to be superseded by a new result soon. This flag is set whenever a new result is being awaited and will be deliverd as soon as the API responds.

It may be set by the Client when the Operation was already active, at which point the Client asks the Exchanges to request a new API response, or by cache exchanges when a temporary, incomplete, or initial cache result has been deliverd, and a new API request has been started in the background. (For partial cache results)

Most commonly, this flag is set for a cached result when the operation is executed using the cache-and-network RequestPolicy.

Generated using TypeDoc