Skip to content

Commit 28511bf

Browse files
committed
validateSchema: remove validation arguments uniqueness
In both 'GraphQLFieldConfig' and 'GraphQLDirectiveConfig' arguments are specified as map and can't duplicate by definition.
1 parent 0b06899 commit 28511bf

File tree

1 file changed

+1
-29
lines changed

1 file changed

+1
-29
lines changed

src/type/validate.js

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -167,30 +167,14 @@ function validateDirectives(context: SchemaValidationContext): void {
167167
// TODO: Ensure proper locations.
168168

169169
// Ensure the arguments are valid.
170-
const argNames = Object.create(null);
171170
for (const arg of directive.args) {
172-
const argName = arg.name;
173-
174171
// Ensure they are named correctly.
175172
validateName(context, arg);
176173

177-
// Ensure they are unique per directive.
178-
if (argNames[argName]) {
179-
context.reportError(
180-
`Argument @${directive.name}(${argName}:) can only be defined once.`,
181-
directive.astNode &&
182-
directive.args
183-
.filter(({ name }) => name === argName)
184-
.map(({ astNode }) => astNode),
185-
);
186-
continue;
187-
}
188-
argNames[argName] = true;
189-
190174
// Ensure the type is an input type.
191175
if (!isInputType(arg.type)) {
192176
context.reportError(
193-
`The type of @${directive.name}(${argName}:) must be Input Type ` +
177+
`The type of @${directive.name}(${arg.name}:) must be Input Type ` +
194178
`but got: ${inspect(arg.type)}.`,
195179
arg.astNode,
196180
);
@@ -286,24 +270,12 @@ function validateFields(
286270
}
287271

288272
// Ensure the arguments are valid
289-
const argNames = Object.create(null);
290273
for (const arg of field.args) {
291274
const argName = arg.name;
292275

293276
// Ensure they are named correctly.
294277
validateName(context, arg);
295278

296-
// Ensure they are unique per field.
297-
if (argNames[argName]) {
298-
context.reportError(
299-
`Field argument ${type.name}.${field.name}(${argName}:) can only be defined once.`,
300-
field.args
301-
.filter(({ name }) => name === argName)
302-
.map(({ astNode }) => astNode),
303-
);
304-
}
305-
argNames[argName] = true;
306-
307279
// Ensure the type is an input type
308280
if (!isInputType(arg.type)) {
309281
context.reportError(

0 commit comments

Comments
 (0)