Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UniqueArgumentDefinitionNamesRule: Improve tests #3441

Merged
merged 3 commits into from Dec 26, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 56 additions & 2 deletions src/validation/__tests__/UniqueArgumentDefinitionNamesRule-test.ts
Expand Up @@ -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
`);
});
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 },
],
},
]);
Expand Down
2 changes: 2 additions & 0 deletions src/validation/rules/UniqueArgumentDefinitionNamesRule.ts
Expand Up @@ -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
IvanGoncharov marked this conversation as resolved.
Show resolved Hide resolved
IvanGoncharov marked this conversation as resolved.
Show resolved Hide resolved
*/
export function UniqueArgumentDefinitionNamesRule(
context: SDLValidationContext,
Expand Down