@@ -201,22 +201,12 @@ describe('Validate: Directives Are Unique Per Location', () => {
201
201
SCHEMA | SCALAR | OBJECT | INTERFACE | UNION | INPUT_OBJECT
202
202
203
203
schema @nonRepeatable @nonRepeatable { query: Dummy }
204
- extend schema @nonRepeatable @nonRepeatable
205
204
206
205
scalar TestScalar @nonRepeatable @nonRepeatable
207
- extend scalar TestScalar @nonRepeatable @nonRepeatable
208
-
209
206
type TestObject @nonRepeatable @nonRepeatable
210
- extend type TestObject @nonRepeatable @nonRepeatable
211
-
212
207
interface TestInterface @nonRepeatable @nonRepeatable
213
- extend interface TestInterface @nonRepeatable @nonRepeatable
214
-
215
208
union TestUnion @nonRepeatable @nonRepeatable
216
- extend union TestUnion @nonRepeatable @nonRepeatable
217
-
218
209
input TestInput @nonRepeatable @nonRepeatable
219
- extend input TestInput @nonRepeatable @nonRepeatable
220
210
` ) . to . deep . equal ( [
221
211
{
222
212
message :
@@ -230,24 +220,32 @@ describe('Validate: Directives Are Unique Per Location', () => {
230
220
message :
231
221
'The directive "@nonRepeatable" can only be used once at this location.' ,
232
222
locations : [
233
- { line : 6 , column : 21 } ,
234
- { line : 6 , column : 36 } ,
223
+ { line : 7 , column : 25 } ,
224
+ { line : 7 , column : 40 } ,
235
225
] ,
236
226
} ,
237
227
{
238
228
message :
239
229
'The directive "@nonRepeatable" can only be used once at this location.' ,
240
230
locations : [
241
- { line : 8 , column : 25 } ,
242
- { line : 8 , column : 40 } ,
231
+ { line : 8 , column : 23 } ,
232
+ { line : 8 , column : 38 } ,
243
233
] ,
244
234
} ,
245
235
{
246
236
message :
247
237
'The directive "@nonRepeatable" can only be used once at this location.' ,
248
238
locations : [
249
- { line : 9 , column : 32 } ,
250
- { line : 9 , column : 47 } ,
239
+ { line : 9 , column : 31 } ,
240
+ { line : 9 , column : 46 } ,
241
+ ] ,
242
+ } ,
243
+ {
244
+ message :
245
+ 'The directive "@nonRepeatable" can only be used once at this location.' ,
246
+ locations : [
247
+ { line : 10 , column : 23 } ,
248
+ { line : 10 , column : 38 } ,
251
249
] ,
252
250
} ,
253
251
{
@@ -258,60 +256,136 @@ describe('Validate: Directives Are Unique Per Location', () => {
258
256
{ line : 11 , column : 38 } ,
259
257
] ,
260
258
} ,
259
+ ] ) ;
260
+ } ) ;
261
+
262
+ it ( 'duplicate directives on SDL extensions' , ( ) => {
263
+ expectSDLErrors ( `
264
+ directive @nonRepeatable on
265
+ SCHEMA | SCALAR | OBJECT | INTERFACE | UNION | INPUT_OBJECT
266
+
267
+ extend schema @nonRepeatable @nonRepeatable
268
+
269
+ extend scalar TestScalar @nonRepeatable @nonRepeatable
270
+ extend type TestObject @nonRepeatable @nonRepeatable
271
+ extend interface TestInterface @nonRepeatable @nonRepeatable
272
+ extend union TestUnion @nonRepeatable @nonRepeatable
273
+ extend input TestInput @nonRepeatable @nonRepeatable
274
+ ` ) . to . deep . equal ( [
261
275
{
262
276
message :
263
277
'The directive "@nonRepeatable" can only be used once at this location.' ,
264
278
locations : [
265
- { line : 12 , column : 30 } ,
266
- { line : 12 , column : 45 } ,
279
+ { line : 5 , column : 21 } ,
280
+ { line : 5 , column : 36 } ,
267
281
] ,
268
282
} ,
269
283
{
270
284
message :
271
285
'The directive "@nonRepeatable" can only be used once at this location.' ,
272
286
locations : [
273
- { line : 14 , column : 31 } ,
274
- { line : 14 , column : 46 } ,
287
+ { line : 7 , column : 32 } ,
288
+ { line : 7 , column : 47 } ,
275
289
] ,
276
290
} ,
277
291
{
278
292
message :
279
293
'The directive "@nonRepeatable" can only be used once at this location.' ,
280
294
locations : [
281
- { line : 15 , column : 38 } ,
282
- { line : 15 , column : 53 } ,
295
+ { line : 8 , column : 30 } ,
296
+ { line : 8 , column : 45 } ,
283
297
] ,
284
298
} ,
285
299
{
286
300
message :
287
301
'The directive "@nonRepeatable" can only be used once at this location.' ,
288
302
locations : [
289
- { line : 17 , column : 23 } ,
290
- { line : 17 , column : 38 } ,
303
+ { line : 9 , column : 38 } ,
304
+ { line : 9 , column : 53 } ,
291
305
] ,
292
306
} ,
293
307
{
294
308
message :
295
309
'The directive "@nonRepeatable" can only be used once at this location.' ,
296
310
locations : [
297
- { line : 18 , column : 30 } ,
298
- { line : 18 , column : 45 } ,
311
+ { line : 10 , column : 30 } ,
312
+ { line : 10 , column : 45 } ,
299
313
] ,
300
314
} ,
301
315
{
302
316
message :
303
317
'The directive "@nonRepeatable" can only be used once at this location.' ,
304
318
locations : [
305
- { line : 20 , column : 23 } ,
306
- { line : 20 , column : 38 } ,
319
+ { line : 11 , column : 30 } ,
320
+ { line : 11 , column : 45 } ,
321
+ ] ,
322
+ } ,
323
+ ] ) ;
324
+ } ) ;
325
+
326
+ it ( 'duplicate directives between SDL definitions and extensions' , ( ) => {
327
+ expectSDLErrors ( `
328
+ directive @nonRepeatable on SCHEMA
329
+
330
+ schema @nonRepeatable { query: Dummy }
331
+ extend schema @nonRepeatable
332
+ ` ) . to . deep . equal ( [
333
+ {
334
+ message :
335
+ 'The directive "@nonRepeatable" can only be used once at this location.' ,
336
+ locations : [
337
+ { line : 4 , column : 14 } ,
338
+ { line : 5 , column : 21 } ,
339
+ ] ,
340
+ } ,
341
+ ] ) ;
342
+
343
+ expectSDLErrors ( `
344
+ directive @nonRepeatable on SCALAR
345
+
346
+ scalar TestScalar @nonRepeatable
347
+ extend scalar TestScalar @nonRepeatable
348
+ scalar TestScalar @nonRepeatable
349
+ ` ) . to . deep . equal ( [
350
+ {
351
+ message :
352
+ 'The directive "@nonRepeatable" can only be used once at this location.' ,
353
+ locations : [
354
+ { line : 4 , column : 25 } ,
355
+ { line : 5 , column : 32 } ,
356
+ ] ,
357
+ } ,
358
+ {
359
+ message :
360
+ 'The directive "@nonRepeatable" can only be used once at this location.' ,
361
+ locations : [
362
+ { line : 4 , column : 25 } ,
363
+ { line : 6 , column : 25 } ,
364
+ ] ,
365
+ } ,
366
+ ] ) ;
367
+
368
+ expectSDLErrors ( `
369
+ directive @nonRepeatable on OBJECT
370
+
371
+ extend type TestObject @nonRepeatable
372
+ type TestObject @nonRepeatable
373
+ extend type TestObject @nonRepeatable
374
+ ` ) . to . deep . equal ( [
375
+ {
376
+ message :
377
+ 'The directive "@nonRepeatable" can only be used once at this location.' ,
378
+ locations : [
379
+ { line : 4 , column : 30 } ,
380
+ { line : 5 , column : 23 } ,
307
381
] ,
308
382
} ,
309
383
{
310
384
message :
311
385
'The directive "@nonRepeatable" can only be used once at this location.' ,
312
386
locations : [
313
- { line : 21 , column : 30 } ,
314
- { line : 21 , column : 45 } ,
387
+ { line : 4 , column : 30 } ,
388
+ { line : 6 , column : 30 } ,
315
389
] ,
316
390
} ,
317
391
] ) ;
0 commit comments