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