From ba5c7165a00bce1a3e753d02a504088675626946 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Fri, 24 Dec 2021 00:46:32 +0100 Subject: [PATCH 1/3] UniqueArgumentDefinitionNamesRule: also test extensions --- .../UniqueArgumentDefinitionNamesRule-test.ts | 58 ++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/src/validation/__tests__/UniqueArgumentDefinitionNamesRule-test.ts b/src/validation/__tests__/UniqueArgumentDefinitionNamesRule-test.ts index 732f11f4eb..cf63202b52 100644 --- a/src/validation/__tests__/UniqueArgumentDefinitionNamesRule-test.ts +++ b/src/validation/__tests__/UniqueArgumentDefinitionNamesRule-test.ts @@ -41,6 +41,14 @@ describe('Validate: Unique argument definition names', () => { someField(foo: String): String } + extend type SomeObject { + anotherField(foo: String): String + } + + extend interface SomeInterface { + anotherField(foo: String): String + } + directive @someDirective(foo: String) on QUERY `); }); @@ -61,6 +69,20 @@ describe('Validate: Unique argument definition names', () => { ): String } + extend type SomeObject { + anotherField( + foo: String + bar: String + ): String + } + + extend interface SomeInterface { + anotherField( + foo: String + bar: String + ): String + } + directive @someDirective( foo: String bar: String @@ -86,6 +108,22 @@ describe('Validate: Unique argument definition names', () => { ): String } + extend type SomeObject { + anotherField( + foo: String + bar: String + bar: String + ): String + } + + extend interface SomeInterface { + anotherField( + bar: String + foo: String + foo: String + ): String + } + directive @someDirective( foo: String bar: String @@ -108,11 +146,27 @@ describe('Validate: Unique argument definition names', () => { { line: 14, column: 11 }, ], }, + { + message: + 'Argument "SomeObject.anotherField(bar:)" can only be defined once.', + locations: [ + { line: 21, column: 11 }, + { line: 22, column: 11 }, + ], + }, + { + message: + 'Argument "SomeInterface.anotherField(foo:)" can only be defined once.', + locations: [ + { line: 29, column: 11 }, + { line: 30, column: 11 }, + ], + }, { message: 'Argument "@someDirective(foo:)" can only be defined once.', locations: [ - { line: 19, column: 9 }, - { line: 21, column: 9 }, + { line: 35, column: 9 }, + { line: 37, column: 9 }, ], }, ]); From 899fefd4f643abcfeba480db81f591c73376a335 Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Fri, 24 Dec 2021 00:49:11 +0100 Subject: [PATCH 2/3] UniqueArgumentDefinitionNamesRule: add link to spec --- src/validation/rules/UniqueArgumentDefinitionNamesRule.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/validation/rules/UniqueArgumentDefinitionNamesRule.ts b/src/validation/rules/UniqueArgumentDefinitionNamesRule.ts index a5bfc9e3b0..24ee461f8a 100644 --- a/src/validation/rules/UniqueArgumentDefinitionNamesRule.ts +++ b/src/validation/rules/UniqueArgumentDefinitionNamesRule.ts @@ -16,6 +16,8 @@ import type { SDLValidationContext } from '../ValidationContext'; * * A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments. * A GraphQL Directive is only valid if all its arguments are uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Argument-Uniqueness */ export function UniqueArgumentDefinitionNamesRule( context: SDLValidationContext, From 29d9649953906b8972fc070c2db2932ff75359f5 Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Sun, 26 Dec 2021 11:27:13 +0200 Subject: [PATCH 3/3] Update src/validation/rules/UniqueArgumentDefinitionNamesRule.ts --- src/validation/rules/UniqueArgumentDefinitionNamesRule.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/validation/rules/UniqueArgumentDefinitionNamesRule.ts b/src/validation/rules/UniqueArgumentDefinitionNamesRule.ts index 24ee461f8a..a5bfc9e3b0 100644 --- a/src/validation/rules/UniqueArgumentDefinitionNamesRule.ts +++ b/src/validation/rules/UniqueArgumentDefinitionNamesRule.ts @@ -16,8 +16,6 @@ import type { SDLValidationContext } from '../ValidationContext'; * * A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments. * A GraphQL Directive is only valid if all its arguments are uniquely named. - * - * See https://spec.graphql.org/draft/#sec-Argument-Uniqueness */ export function UniqueArgumentDefinitionNamesRule( context: SDLValidationContext,