diff --git a/libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo/ast/internal/definitions.kt b/libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo/ast/internal/definitions.kt index e65c5dcc04a..a5e8c15e4ef 100644 --- a/libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo/ast/internal/definitions.kt +++ b/libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo/ast/internal/definitions.kt @@ -310,7 +310,7 @@ internal val builtinsDefinitionsStr = """ directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT directive @deprecated( - reason: String = "No longer supported" + reason: String! = "No longer supported" ) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE directive @defer( diff --git a/libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo/ast/introspection/introspection_reader.kt b/libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo/ast/introspection/introspection_reader.kt index 9bbe206874e..a337546f163 100644 --- a/libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo/ast/introspection/introspection_reader.kt +++ b/libraries/apollo-ast/src/commonMain/kotlin/com/apollographql/apollo/ast/introspection/introspection_reader.kt @@ -369,16 +369,11 @@ private class GQLDocumentBuilder(private val introspectionSchema: IntrospectionS } /** - * This assumes the case where `deprecationReason == null && isDeprecated` is not valid - * which is unclear from reading the spec as the below seems allowed: + * This assumes the case where `deprecationReason == null && isDeprecated` is not valid. * - * ``` - * type Query { - * foo: Int @deprecated(reason: null) - * } - * ``` + * See https://github.com/graphql/graphql-spec/pull/1040 * - * If there are legit use cases for `@deprecated(reason: null)` we should update this function + * If a legacy schema contains `@deprecated(reason: null)`, the field appears as non-deprecated. */ fun makeDirectives(deprecationReason: String?): List { if (deprecationReason == null) { diff --git a/libraries/apollo-ast/test-fixtures/sdl/type_redefinitions.expected b/libraries/apollo-ast/test-fixtures/sdl/type_redefinitions.expected index aaa7e6dcc5b..3eb483ef630 100644 --- a/libraries/apollo-ast/test-fixtures/sdl/type_redefinitions.expected +++ b/libraries/apollo-ast/test-fixtures/sdl/type_redefinitions.expected @@ -150,7 +150,7 @@ directive @skip (if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT directive @include (if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT -directive @deprecated (reason: String = "No longer supported") on FIELD_DEFINITION|ARGUMENT_DEFINITION|INPUT_FIELD_DEFINITION|ENUM_VALUE +directive @deprecated (reason: String! = "No longer supported") on FIELD_DEFINITION|ARGUMENT_DEFINITION|INPUT_FIELD_DEFINITION|ENUM_VALUE directive @defer (label: String, if: Boolean! = true) on FRAGMENT_SPREAD|INLINE_FRAGMENT diff --git a/tests/sample-server/graphql/schema.graphqls b/tests/sample-server/graphql/schema.graphqls index 2ee11d415bb..3a82ef9889b 100644 --- a/tests/sample-server/graphql/schema.graphqls +++ b/tests/sample-server/graphql/schema.graphqls @@ -190,7 +190,7 @@ directive @skip (if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT directive @include (if: Boolean!) on FIELD|FRAGMENT_SPREAD|INLINE_FRAGMENT -directive @deprecated (reason: String = "No longer supported") on FIELD_DEFINITION|ARGUMENT_DEFINITION|INPUT_FIELD_DEFINITION|ENUM_VALUE +directive @deprecated (reason: String! = "No longer supported") on FIELD_DEFINITION|ARGUMENT_DEFINITION|INPUT_FIELD_DEFINITION|ENUM_VALUE directive @defer (label: String, if: Boolean! = true) on FRAGMENT_SPREAD|INLINE_FRAGMENT