Optional
Readonly
Internal
_instanceA unique identity for GraphQL mutations.
This is an internal property set by the Client
to an identity of type OperationInstance.
An OperationInstance
is an identifier that's used to tell two mutation operations with identical
query
documents and variables
apart from one another.
Optional
additionalAdditional cache tags for @urql/core
's document cacheExchange
.
The built-in cacheExchange in @urql/core
is a document cache that uses __typename
s in
mutation results to invalidate past, cached queries.
The additionalTypenames
array may be set to the list of custom typenames whenever a result may
not deliver __typename
properties, e.g. when an empty array may be sent.
By providing a list of custom typenames you may "tag" a result as containing a certain type, which
helps the document cache associate mutations with queries when either don't actually contain a
__typename
in the JSON result.
Optional
fetchThe fetch
function used to make API calls.
This is the fetch polyfill used by any fetch exchange to make an API request. By default, when this
option isn't set, any fetch exchange will attempt to use the globally available fetch
function
to make a request instead.
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API for the Fetch API spec.
Optional
init: RequestInitOptional
fetchAdditional options passed to the fetch
call on API requests.
The options in this object or an object returned by a callback function will be merged into the
RequestInit options passed to the fetch
call.
https://developer.mozilla.org/en-US/docs/Web/API/fetch for a description of this object.
Optional
fetchAllows the fetchExchange
to handle subscriptions.
When set to true
, subscriptions are allowed to be handled by the fetchExchange and will
be sent using a fetch
call as GraphQL over HTTP requests.
This may be enabled on fetchSubscriptions when your API supports the
text/event-stream
and multipart/mixed
response protocols and is able to use them to
respond with subscription results.
Optional
metaMetadata that annotates an Operation
in development for the urql-devtools
.
This is metadata that is used by the urql-devtools
to get more information about Operation
s and
OperationResult
s and is filled in by exchanges across the codebase in development.
This data is not for production use and hence shouldn't be used or relied upon directly. In production, this may not be set by default exchanges.
Optional
preferInstructs fetch exchanges to use a GET request.
By default, GraphQL over HTTP requests are always sent as POST requests with a JSON body. However, sometimes it's preferable to send a GET request instead, for instance, for caching with or without persisted queries.
When set to true
, the preferGetMethod
instructs fetch exchanges to instead send a GET request
for query operations.
Additionally, urql
's built-in fetch exchanges will default to 'within-url-limit'
and not send a GET request
when the resulting URL would be 2,048 characters or longer. This can be forced and circumvented by setting
this option to 'force'
.
The request and caching strategy instructing cache exchanges how to treat cached results.
The RequestPolicy instructing cache exchanges how to use and treat their cached results.
By default cache-first
is set and used, which will use cache results, and only make an API request
on a cache miss.
Optional
suspenseA configuration flag indicating whether this operation may trigger "Suspense".
This configuration flag is reserved for urql
(react-urql
) and @urql/preact
to activate or
deactivate support for Suspense, and is ignored in other bindings.
When activated here and on Client.suspense
it allows the bindings to "suspend" instead
of returning a loading state, which will stop updates in a querying component and instead cascade
to a higher suspense boundary for a loading state.
https://beta.reactjs.org/blog/2022/03/29/react-v18#new-suspense-features for more information on React Suspense.
The url
passed to the fetch
call on API requests.
https://developer.mozilla.org/en-US/docs/Web/API/fetch for a description of the fetch
calls.
Generated using TypeDoc
Additional metadata for an
Operation
used to execute it.Remarks
The
OperationContext
is found on context and gives exchanges additional metadata and options used to execute the operation.The context can often be changed on a per-operation basis, meaning, APIs on the Client or bindings can pass a partial context that alters these options for a single operation.
The
OperationContext
is populated mostly from the initial options passed to theClient
at its time of creation, but may also be modified by exchanges when an Operation is passed through to the next exchange or when a result is returned.