diff --git a/.changeset/seven-needles-remember.md b/.changeset/seven-needles-remember.md new file mode 100644 index 00000000000..7b738e2c5f1 --- /dev/null +++ b/.changeset/seven-needles-remember.md @@ -0,0 +1,5 @@ +--- +'@apollo/client': patch +--- + +[#10509](https://github.com/apollographql/apollo-client/pull/10509) introduced some helpers for determining the type of operation for a GraphQL query. This imported the `OperationTypeNode` from graphql-js which is not available in GraphQL 14. To maintain compatibility with graphql-js v14, this has been reverted to use plain strings. diff --git a/src/utilities/graphql/operations.ts b/src/utilities/graphql/operations.ts index ef390e8f631..680991d0e6a 100644 --- a/src/utilities/graphql/operations.ts +++ b/src/utilities/graphql/operations.ts @@ -1,19 +1,21 @@ -import { OperationTypeNode } from 'graphql'; import type { DocumentNode } from '../../core/index.js'; import { getOperationDefinition } from './getFromAST.js'; -function isOperation(document: DocumentNode, operation: OperationTypeNode) { +function isOperation( + document: DocumentNode, + operation: 'query' | 'mutation' | 'subscription' +) { return getOperationDefinition(document)?.operation === operation; } export function isMutationOperation(document: DocumentNode) { - return isOperation(document, OperationTypeNode.MUTATION); + return isOperation(document, 'mutation'); } export function isQueryOperation(document: DocumentNode) { - return isOperation(document, OperationTypeNode.QUERY); + return isOperation(document, 'query'); } export function isSubscriptionOperation(document: DocumentNode) { - return isOperation(document, OperationTypeNode.SUBSCRIPTION); + return isOperation(document, 'subscription'); }