1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.getOperationAST = getOperationAST;
|
7 |
|
8 | var _kinds = require("../language/kinds");
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function getOperationAST(documentAST, operationName) {
|
16 | var operation = null;
|
17 |
|
18 | for (var _i2 = 0, _documentAST$definiti2 = documentAST.definitions; _i2 < _documentAST$definiti2.length; _i2++) {
|
19 | var definition = _documentAST$definiti2[_i2];
|
20 |
|
21 | if (definition.kind === _kinds.Kind.OPERATION_DEFINITION) {
|
22 | if (!operationName) {
|
23 |
|
24 |
|
25 |
|
26 | if (operation) {
|
27 | return null;
|
28 | }
|
29 |
|
30 | operation = definition;
|
31 | } else if (definition.name && definition.name.value === operationName) {
|
32 | return definition;
|
33 | }
|
34 | }
|
35 | }
|
36 |
|
37 | return operation;
|
38 | }
|