Skip to content
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

Expand @deprecated to Objects #997

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
30 changes: 29 additions & 1 deletion spec/Section 3 -- Type System.md
Original file line number Diff line number Diff line change
Expand Up @@ -2057,7 +2057,7 @@ condition is false.
```graphql
directive @deprecated(
reason: String = "No longer supported"
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE
) on FIELD_DEFINITION | ARGUMENT_DEFINITION | INPUT_FIELD_DEFINITION | ENUM_VALUE | OBJECT
```

The `@deprecated` _built-in directive_ is used within the type system definition
Expand Down Expand Up @@ -2098,6 +2098,34 @@ type ExampleType {
To deprecate a required argument or input field, it must first be made optional
by either changing the type to nullable or adding a default value.

The `@deprecated` directive is useful for object types that are included in unions or
interfaces. Deprecating the type indicates to clients that the server will no longer be returning
this type and clients should remove references to this type in their queries.

```graphql example
type Query {
returnsUnion: MyUnion
}

union MyUnion = ExampleType | DeprecatedType

type DeprecatedType @deprecated {
id: ID
}
```

The `@deprecated` directive should not appear on object types that are referenced by non-deprecated fields.

```graphql counter-example
type Query {
returnsDeprecatedType: DeprecatedType
}

type DeprecatedType @deprecated {
id: ID
}
```

### @specifiedBy

```graphql
Expand Down
8 changes: 6 additions & 2 deletions spec/Section 4 -- Introspection.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ CommonMark-compliant Markdown renderer.
**Deprecation**

To support the management of backwards compatibility, GraphQL fields, arguments,
input fields, and enum values can indicate whether or not they are deprecated
input fields, enum values, and objects can indicate whether or not they are deprecated
(`isDeprecated: Boolean`) along with a description of why it is deprecated
(`deprecationReason: String`).

Expand All @@ -126,7 +126,7 @@ which are fully defined in the sections below.
```graphql
type __Schema {
description: String
types: [__Type!]!
types(includeDeprecated: Boolean = false): [__Type!]!
queryType: __Type!
mutationType: __Type
subscriptionType: __Type
Expand All @@ -151,6 +151,8 @@ type __Type {
ofType: __Type
# may be non-null for custom SCALAR, otherwise null.
specifiedByURL: String
isDeprecated: Boolean!
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. __Type includes non-objects (unions, interfaces, anything in __TypeKind). Maybe this field should be nullable like possibleTypes? Or defaults to false for any type that can't be deprecated?

deprecationReason: String
}

enum __TypeKind {
Expand Down Expand Up @@ -236,6 +238,8 @@ Fields\:
- `types` must return the set of all named types contained within this schema.
Any named type which can be found through a field of any introspection type
must be included in this set.
- Accepts the argument `includeDeprecated` which defaults to {false}. If
{true}, deprecated fields are also returned.
- `directives` must return the set of all directives available within this
schema including all built-in directives.

Expand Down