1 | import { Kind } from '../language/kinds.mjs';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export function getOperationAST(documentAST, operationName) {
|
9 | let operation = null;
|
10 |
|
11 | for (const definition of documentAST.definitions) {
|
12 | if (definition.kind === Kind.OPERATION_DEFINITION) {
|
13 | var _definition$name;
|
14 |
|
15 | if (operationName == null) {
|
16 |
|
17 |
|
18 |
|
19 | if (operation) {
|
20 | return null;
|
21 | }
|
22 |
|
23 | operation = definition;
|
24 | } else if (
|
25 | ((_definition$name = definition.name) === null ||
|
26 | _definition$name === void 0
|
27 | ? void 0
|
28 | : _definition$name.value) === operationName
|
29 | ) {
|
30 | return definition;
|
31 | }
|
32 | }
|
33 | }
|
34 |
|
35 | return operation;
|
36 | }
|