Skip to content

Make deprecation.reason non-nullable #6311

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

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<GQLDirective> {
if (deprecationReason == null) {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/sample-server/graphql/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading