Skip to content

Commit 9af60c9

Browse files
authored
Make deprecation.reason non-nullable (#6311)
* Make deprecation.reason non-nullable * update apolloDump * fix test fixture
1 parent d140576 commit 9af60c9

File tree

4 files changed

+6
-11
lines changed

4 files changed

+6
-11
lines changed

libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo/ast/internal/definitions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ internal val builtinsDefinitionsStr = """
310310
directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
311311
312312
directive @deprecated(
313-
reason: String = "No longer supported"
313+
reason: String! = "No longer supported"
314314
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE
315315
316316
directive @defer(

libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo/ast/introspection/introspection_reader.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -369,16 +369,11 @@ private class GQLDocumentBuilder(private val introspectionSchema: IntrospectionS
369369
}
370370

371371
/**
372-
* This assumes the case where `deprecationReason == null && isDeprecated` is not valid
373-
* which is unclear from reading the spec as the below seems allowed:
372+
* This assumes the case where `deprecationReason == null && isDeprecated` is not valid.
374373
*
375-
* ```
376-
* type Query {
377-
* foo: Int @deprecated(reason: null)
378-
* }
379-
* ```
374+
* See https://github.com/graphql/graphql-spec/pull/1040
380375
*
381-
* If there are legit use cases for `@deprecated(reason: null)` we should update this function
376+
* If a legacy schema contains `@deprecated(reason: null)`, the field appears as non-deprecated.
382377
*/
383378
fun makeDirectives(deprecationReason: String?): List<GQLDirective> {
384379
if (deprecationReason == null) {

libraries/apollo-ast/test-fixtures/sdl/type_redefinitions.expected

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/sample-server/graphql/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ directive @skip (if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT
190190

191191
directive @include (if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT
192192

193-
directive @deprecated (reason: String = "No longer supported") on FIELD_DEFINITION|ARGUMENT_DEFINITION|INPUT_FIELD_DEFINITION|ENUM_VALUE
193+
directive @deprecated (reason: String! = "No longer supported") on FIELD_DEFINITION|ARGUMENT_DEFINITION|INPUT_FIELD_DEFINITION|ENUM_VALUE
194194

195195
directive @defer (label: String, if: Boolean! = true) on FRAGMENT_SPREAD|INLINE_FRAGMENT
196196

0 commit comments

Comments
 (0)