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

Deprecated directive #384

Merged
merged 1 commit into from
May 8, 2016
Merged

Deprecated directive #384

merged 1 commit into from
May 8, 2016

Conversation

leebyron
Copy link
Contributor

@leebyron leebyron commented May 7, 2016

This adds a new directive as part of the experimental schema language:

directive @deprecated(reason: String = "No longer supported") on FIELD_DEFINITION | ENUM_VALUE

It also adds support for this directive in the schemaPrinter and buildASTSchema.

Additionally exports a new helper specifiedDirectives which is encoured to be used when addressing the collection of all directives defined by the spec. The @deprecated directive is optimistically added to this collection. While it's currently experimental, it will become part of the schema definition language RFC.

@ghost ghost added the CLA Signed label May 7, 2016
@leebyron
Copy link
Contributor Author

leebyron commented May 7, 2016

This is a follow-up to #376 cc @helfer, @OlegIlyenko

@leebyron
Copy link
Contributor Author

leebyron commented May 7, 2016

Example of use:

schema {
  query: Query
}

enum MyEnum {
  VALUE
  OLD_VALUE @deprecated
  OTHER_VALUE @deprecated(reason: "Terrible reasons")
}

type Query {
  field1: String @deprecated
  field2: Int @deprecated(reason: "Because I said so")
  enum: MyEnum
}

@coveralls
Copy link

Coverage Status

Coverage increased (+0.007%) to 98.244% when pulling 498f479 on deprecated-directive into 0aa78f6 on master.

name: 'deprecated',
description:
'Marks an element of a GraphQL schema as no longer supported.',
locations: [
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we intend to support more directive locations later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Possibly so. Right now these are the only two kinds of things in the schema which can be deprecated according to the spec.

@robzhu
Copy link
Contributor

robzhu commented May 7, 2016

Looks great! This will be a good example for building custom directives.

This adds a new directive as part of the experimental schema language:

```
directive @deprecated(reason: String = "No longer supported") on FIELD_DEFINITION | ENUM_VALUE
```

It also adds support for this directive in the schemaPrinter and buildASTSchema.

Additionally exports a new helper `specifiedDirectives` which is encoured to be used when addressing the collection of all directives defined by the spec. The `@deprecated` directive is optimistically added to this collection. While it's currently experimental, it will become part of the schema definition language RFC.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.007%) to 98.244% when pulling 6796fad on deprecated-directive into 0aa78f6 on master.

@leebyron leebyron merged commit 5375c9b into master May 8, 2016
@leebyron leebyron deleted the deprecated-directive branch May 8, 2016 21:56
sogko added a commit to sogko/graphql-js that referenced this pull request Jun 1, 2016
* master: (26 commits)
  0.6.0
  Validation: improving overlapping fields quality (graphql#386)
  Validation: context.getFragmentSpreads now accepts selectionSet rather than fragment AST node
  Factor out more closure functions
  Factor out closure functions to normal functions
  Deprecated directive (graphql#384)
  RFC: Directive location: schema definition (graphql#382)
  RFC: Schema Language Directives (graphql#376)
  Export introspection in public API
  Export directive definitions. (graphql#381)
  BUG: Ensure building AST schema does not exclude @Skip and @include (graphql#380)
  documentation of schema constructor
  Revert "Remove all 'instanceof GraphQLSchema' checks" (graphql#377)
  remove all 'instanceof GraphQLSchema' checks (graphql#371)
  Error logging for new interface type semantics (graphql#350)
  Nit: Missing case in grammar for TypeSystemDefinition in comment
  Bug: printer can print non-parsable value
  Factor out suggestion quoting utility
  Minor refactoring
  Minor refactoring of error messages for unknown fields
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants