1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.LoneAnonymousOperationRule = LoneAnonymousOperationRule;
|
7 |
|
8 | var _GraphQLError = require("../../error/GraphQLError.js");
|
9 |
|
10 | var _kinds = require("../../language/kinds.js");
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 | function LoneAnonymousOperationRule(context) {
|
19 | var operationCount = 0;
|
20 | return {
|
21 | Document: function Document(node) {
|
22 | operationCount = node.definitions.filter(function (definition) {
|
23 | return definition.kind === _kinds.Kind.OPERATION_DEFINITION;
|
24 | }).length;
|
25 | },
|
26 | OperationDefinition: function OperationDefinition(node) {
|
27 | if (!node.name && operationCount > 1) {
|
28 | context.reportError(new _GraphQLError.GraphQLError('This anonymous operation must be the only defined operation.', node));
|
29 | }
|
30 | }
|
31 | };
|
32 | }
|