@@ -171,18 +171,27 @@ function validateDirectives(context: SchemaValidationContext): void {
171
171
// TODO: Ensure proper locations.
172
172
173
173
// Ensure the arguments are valid.
174
+ const knownArgNames = Object . create ( null ) ;
174
175
for ( const arg of directive . args ) {
175
176
// Ensure they are named correctly.
176
177
validateName ( context , arg ) ;
177
-
178
+ const argName = arg . name ;
178
179
// Ensure the type is an input type.
179
180
if ( ! isInputType ( arg . type ) ) {
180
181
context . reportError (
181
- `The type of @${ directive . name } (${ arg . name } :) must be Input Type ` +
182
- `but got: ${ inspect ( arg . type ) } .` ,
182
+ `The type of @${ directive . name } (${ argName } :) must be Input Type ` +
183
+ `but got: ${ inspect ( arg . type ) } .` ,
183
184
arg . astNode ,
184
185
) ;
185
186
}
187
+ if ( knownArgNames [ argName ] ) {
188
+ context . reportError (
189
+ `There can be only one argument named "${ argName } ".` ,
190
+ directive ?. astNode ,
191
+ ) ;
192
+ } else {
193
+ knownArgNames [ argName ] = argName ;
194
+ }
186
195
}
187
196
}
188
197
}
@@ -274,6 +283,7 @@ function validateFields(
274
283
}
275
284
276
285
// Ensure the arguments are valid
286
+ const knownArgNames = Object . create ( null ) ;
277
287
for ( const arg of field . args ) {
278
288
const argName = arg . name ;
279
289
@@ -288,6 +298,14 @@ function validateFields(
288
298
arg . astNode ?. type ,
289
299
) ;
290
300
}
301
+ if ( knownArgNames [ argName ] ) {
302
+ context . reportError (
303
+ `There can be only one argument named "${ argName } ".` ,
304
+ field . astNode ?. type ,
305
+ ) ;
306
+ } else {
307
+ knownArgNames [ argName ] = argName ;
308
+ }
291
309
}
292
310
}
293
311
}
0 commit comments