From a95392bdeda2fd13907f1d0783097fb37d548e2a Mon Sep 17 00:00:00 2001 From: Martin Bonnin Date: Fri, 22 Nov 2024 18:53:54 +0100 Subject: [PATCH] Make deprecation.reason non-nullable See https://github.com/graphql/graphql-spec/pull/1040 --- src/type/__tests__/introspection-test.ts | 10 +++++++--- src/type/directives.ts | 2 +- src/utilities/__tests__/printSchema-test.ts | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/type/__tests__/introspection-test.ts b/src/type/__tests__/introspection-test.ts index 803e346834..9cdfe70697 100644 --- a/src/type/__tests__/introspection-test.ts +++ b/src/type/__tests__/introspection-test.ts @@ -978,9 +978,13 @@ describe('Introspection', () => { defaultValue: '"No longer supported"', name: 'reason', type: { - kind: 'SCALAR', - name: 'String', - ofType: null, + kind: 'NON_NULL', + name: null, + ofType: { + kind: 'SCALAR', + name: 'String', + ofType: null, + }, }, }, ], diff --git a/src/type/directives.ts b/src/type/directives.ts index 23faa33717..16b8ce6c2b 100644 --- a/src/type/directives.ts +++ b/src/type/directives.ts @@ -223,7 +223,7 @@ export const GraphQLDeprecatedDirective: GraphQLDirective = ], args: { reason: { - type: GraphQLString, + type: new GraphQLNonNull(GraphQLString), description: 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).', defaultValue: DEFAULT_DEPRECATION_REASON, diff --git a/src/utilities/__tests__/printSchema-test.ts b/src/utilities/__tests__/printSchema-test.ts index ac9002e388..0183436ec8 100644 --- a/src/utilities/__tests__/printSchema-test.ts +++ b/src/utilities/__tests__/printSchema-test.ts @@ -803,7 +803,7 @@ describe('Type System Printer', () => { """ Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/). """ - reason: String = "No longer supported" + reason: String! = "No longer supported" ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE """Exposes a URL that specifies the behavior of this scalar."""