blob: f3fe5993fac03c6f685d05b55726e8022c3f8de9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.UniqueArgumentNamesRule = UniqueArgumentNamesRule;
var _GraphQLError = require("../../error/GraphQLError.js");
/**
* Unique argument names
*
* A GraphQL field or directive is only valid if all supplied arguments are
* uniquely named.
*/
function UniqueArgumentNamesRule(context) {
var knownArgNames = Object.create(null);
return {
Field: function Field() {
knownArgNames = Object.create(null);
},
Directive: function Directive() {
knownArgNames = Object.create(null);
},
Argument: function Argument(node) {
var argName = node.name.value;
if (knownArgNames[argName]) {
context.reportError(new _GraphQLError.GraphQLError("There can be only one argument named \"".concat(argName, "\"."), [knownArgNames[argName], node.name]));
} else {
knownArgNames[argName] = node.name;
}
return false;
}
};
}
|