Skip to main content
Version: v10.0.0

matchGqlOperation

Matches the cache keys of every request of a GraphQL operation - with any variables, params, query params and method. Pass it to client.cache.invalidate() after a mutation, so the active queries of the operation refetch, like

refetchQueries in Apollo.

  • A document matches its requests on every url path of the document option.
  • A request matches the requests of its document on its own url path.
  • Documents with the same operation name but other selections are other operations, they do not match.

Import
import { matchGqlOperation } from "@hyper-fetch/graphql"

Usage​

await updateUser.send({ payload: { id: "1", name: "Ann" } });
client.cache.invalidate(matchGqlOperation(GetUserDocument));

Parameters​

matchGqlOperation(operation: GraphQlEndpointType | RequestInstance)
Parameters
NameTypeDescription
operation
GraphQlEndpointType | RequestInstance

Returns​

RegExp