From 077740766832cf552d6f094c47fcdaaf63ec8628 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Mon, 17 Jul 2023 09:52:48 +0200 Subject: [PATCH 1/6] Improve description for `@oneOf` directive Follow up from https://github.com/graphql/graphql-js/pull/3513. I think it is fine for the spec text in https://github.com/graphql/graphql-spec/pull/825 to refer to `OneOf Input Object`, as the spec explains what that is in another section. In a directive definition, that explanation by itself does not make much sense without prior knowledge. --- src/type/directives.ts | 4 ++-- src/utilities/__tests__/printSchema-test.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/type/directives.ts b/src/type/directives.ts index 63acf6056e..645b2fa1b1 100644 --- a/src/type/directives.ts +++ b/src/type/directives.ts @@ -248,11 +248,11 @@ export const GraphQLSpecifiedByDirective: GraphQLDirective = }); /** - * Used to declare an Input Object as a OneOf Input Objects. + * Used to indicate an Input Object is a OneOf Input Object. */ export const GraphQLOneOfDirective: GraphQLDirective = new GraphQLDirective({ name: 'oneOf', - description: 'Indicates an Input Object is a OneOf Input Object.', + description: 'Indicates that exactly one field must be supplied and that field must not be `null`.', locations: [DirectiveLocation.INPUT_OBJECT], args: {}, }); diff --git a/src/utilities/__tests__/printSchema-test.ts b/src/utilities/__tests__/printSchema-test.ts index 8940cafbe5..f3801db6e5 100644 --- a/src/utilities/__tests__/printSchema-test.ts +++ b/src/utilities/__tests__/printSchema-test.ts @@ -795,7 +795,7 @@ describe('Type System Printer', () => { url: String! ) on SCALAR - """Indicates an Input Object is a OneOf Input Object.""" + """Indicates that exactly one field must be supplied and that field must not be \`null\`.""" directive @oneOf on INPUT_OBJECT """ From 2d4386c24b455449897dbd13fdc574761d678fe0 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Mon, 17 Jul 2023 09:56:42 +0200 Subject: [PATCH 2/6] Fix expected schema output --- src/utilities/__tests__/printSchema-test.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utilities/__tests__/printSchema-test.ts b/src/utilities/__tests__/printSchema-test.ts index f3801db6e5..e538b6684c 100644 --- a/src/utilities/__tests__/printSchema-test.ts +++ b/src/utilities/__tests__/printSchema-test.ts @@ -795,7 +795,9 @@ describe('Type System Printer', () => { url: String! ) on SCALAR - """Indicates that exactly one field must be supplied and that field must not be \`null\`.""" + """ + Indicates that exactly one field must be supplied and that field must not be \`null\`. + """ directive @oneOf on INPUT_OBJECT """ From 717bc21fe52e96c5ee2bf2e05779c34c350a47a5 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Mon, 17 Jul 2023 10:05:01 +0200 Subject: [PATCH 3/6] prettier --- src/type/directives.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/type/directives.ts b/src/type/directives.ts index 645b2fa1b1..17466ad683 100644 --- a/src/type/directives.ts +++ b/src/type/directives.ts @@ -252,7 +252,8 @@ export const GraphQLSpecifiedByDirective: GraphQLDirective = */ export const GraphQLOneOfDirective: GraphQLDirective = new GraphQLDirective({ name: 'oneOf', - description: 'Indicates that exactly one field must be supplied and that field must not be `null`.', + description: + 'Indicates that exactly one field must be supplied and that field must not be `null`.', locations: [DirectiveLocation.INPUT_OBJECT], args: {}, }); From f74823ae01320cca48521800d122ef9c791349d5 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Tue, 18 Jul 2023 09:53:00 +0200 Subject: [PATCH 4/6] Simplify wording --- src/type/directives.ts | 2 +- src/utilities/__tests__/printSchema-test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/type/directives.ts b/src/type/directives.ts index 17466ad683..73c3370b20 100644 --- a/src/type/directives.ts +++ b/src/type/directives.ts @@ -253,7 +253,7 @@ export const GraphQLSpecifiedByDirective: GraphQLDirective = export const GraphQLOneOfDirective: GraphQLDirective = new GraphQLDirective({ name: 'oneOf', description: - 'Indicates that exactly one field must be supplied and that field must not be `null`.', + 'Indicates that exactly one field must be supplied and not `null`.', locations: [DirectiveLocation.INPUT_OBJECT], args: {}, }); diff --git a/src/utilities/__tests__/printSchema-test.ts b/src/utilities/__tests__/printSchema-test.ts index e538b6684c..a7adab6dbf 100644 --- a/src/utilities/__tests__/printSchema-test.ts +++ b/src/utilities/__tests__/printSchema-test.ts @@ -796,7 +796,7 @@ describe('Type System Printer', () => { ) on SCALAR """ - Indicates that exactly one field must be supplied and that field must not be \`null\`. + Indicates that exactly one field must be supplied and not \`null\`. """ directive @oneOf on INPUT_OBJECT From 9cff863d5112f2bb5eb26ce9d75fde118a26d7c4 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Tue, 18 Jul 2023 09:56:48 +0200 Subject: [PATCH 5/6] one line --- src/utilities/__tests__/printSchema-test.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utilities/__tests__/printSchema-test.ts b/src/utilities/__tests__/printSchema-test.ts index a7adab6dbf..b046f3ed5b 100644 --- a/src/utilities/__tests__/printSchema-test.ts +++ b/src/utilities/__tests__/printSchema-test.ts @@ -795,9 +795,7 @@ describe('Type System Printer', () => { url: String! ) on SCALAR - """ - Indicates that exactly one field must be supplied and not \`null\`. - """ + """Indicates that exactly one field must be supplied and not \`null\`.""" directive @oneOf on INPUT_OBJECT """ From f1a3b343d296119982e29a3f4999cd8891ee6832 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Thu, 20 Jul 2023 09:55:30 +0200 Subject: [PATCH 6/6] Solve bracketing problem, omit that --- src/type/directives.ts | 2 +- src/utilities/__tests__/printSchema-test.ts | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/type/directives.ts b/src/type/directives.ts index 73c3370b20..48e90c5531 100644 --- a/src/type/directives.ts +++ b/src/type/directives.ts @@ -253,7 +253,7 @@ export const GraphQLSpecifiedByDirective: GraphQLDirective = export const GraphQLOneOfDirective: GraphQLDirective = new GraphQLDirective({ name: 'oneOf', description: - 'Indicates that exactly one field must be supplied and not `null`.', + 'Indicates exactly one field must be supplied and this field must not be `null`.', locations: [DirectiveLocation.INPUT_OBJECT], args: {}, }); diff --git a/src/utilities/__tests__/printSchema-test.ts b/src/utilities/__tests__/printSchema-test.ts index b046f3ed5b..7f64ad349d 100644 --- a/src/utilities/__tests__/printSchema-test.ts +++ b/src/utilities/__tests__/printSchema-test.ts @@ -795,7 +795,9 @@ describe('Type System Printer', () => { url: String! ) on SCALAR - """Indicates that exactly one field must be supplied and not \`null\`.""" + """ + Indicates exactly one field must be supplied and this field must not be \`null\`. + """ directive @oneOf on INPUT_OBJECT """