Skip to content

Commit 4473e92

Browse files
authored
Update operation helpers to use raw strings instead of OperationTypeNode (#11071)
1 parent 213bde2 commit 4473e92

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

.changeset/seven-needles-remember.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@apollo/client': patch
3+
---
4+
5+
[#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.

src/utilities/graphql/operations.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
1-
import { OperationTypeNode } from 'graphql';
21
import type { DocumentNode } from '../../core/index.js';
32
import { getOperationDefinition } from './getFromAST.js';
43

5-
function isOperation(document: DocumentNode, operation: OperationTypeNode) {
4+
function isOperation(
5+
document: DocumentNode,
6+
operation: 'query' | 'mutation' | 'subscription'
7+
) {
68
return getOperationDefinition(document)?.operation === operation;
79
}
810

911
export function isMutationOperation(document: DocumentNode) {
10-
return isOperation(document, OperationTypeNode.MUTATION);
12+
return isOperation(document, 'mutation');
1113
}
1214

1315
export function isQueryOperation(document: DocumentNode) {
14-
return isOperation(document, OperationTypeNode.QUERY);
16+
return isOperation(document, 'query');
1517
}
1618

1719
export function isSubscriptionOperation(document: DocumentNode) {
18-
return isOperation(document, OperationTypeNode.SUBSCRIPTION);
20+
return isOperation(document, 'subscription');
1921
}

0 commit comments

Comments
 (0)