1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.UniqueOperationNamesRule = UniqueOperationNamesRule;
|
7 |
|
8 | var _GraphQLError = require("../../error/GraphQLError.js");
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 | function UniqueOperationNamesRule(context) {
|
16 | var knownOperationNames = Object.create(null);
|
17 | return {
|
18 | OperationDefinition: function OperationDefinition(node) {
|
19 | var operationName = node.name;
|
20 |
|
21 | if (operationName) {
|
22 | if (knownOperationNames[operationName.value]) {
|
23 | context.reportError(new _GraphQLError.GraphQLError("There can be only one operation named \"".concat(operationName.value, "\"."), [knownOperationNames[operationName.value], operationName]));
|
24 | } else {
|
25 | knownOperationNames[operationName.value] = operationName;
|
26 | }
|
27 | }
|
28 |
|
29 | return false;
|
30 | },
|
31 | FragmentDefinition: function FragmentDefinition() {
|
32 | return false;
|
33 | }
|
34 | };
|
35 | }
|