1 | import { GraphQLError } from "../../error/GraphQLError.mjs";
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | export function UniqueOperationNamesRule(context) {
|
9 | var knownOperationNames = Object.create(null);
|
10 | return {
|
11 | OperationDefinition: function OperationDefinition(node) {
|
12 | var operationName = node.name;
|
13 |
|
14 | if (operationName) {
|
15 | if (knownOperationNames[operationName.value]) {
|
16 | context.reportError(new GraphQLError("There can be only one operation named \"".concat(operationName.value, "\"."), [knownOperationNames[operationName.value], operationName]));
|
17 | } else {
|
18 | knownOperationNames[operationName.value] = operationName;
|
19 | }
|
20 | }
|
21 |
|
22 | return false;
|
23 | },
|
24 | FragmentDefinition: function FragmentDefinition() {
|
25 | return false;
|
26 | }
|
27 | };
|
28 | }
|