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 | for (var i = 0; i < documentAST.definitions.length; i++) {
|
18 | var definition = documentAST.definitions[i];
|
19 | if (definition.kind === _kinds.OPERATION_DEFINITION) {
|
20 | if (!operationName) {
|
21 |
|
22 |
|
23 |
|
24 | if (operation) {
|
25 | return null;
|
26 | }
|
27 | operation = definition;
|
28 | } else if (definition.name && definition.name.value === operationName) {
|
29 | return definition;
|
30 | }
|
31 | }
|
32 | }
|
33 | return operation;
|
34 | } |
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
\ | No newline at end of file |