graphql-directive-deprecated
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

Build Status Coverage Status dependencies Status devDependencies Status peerDependencies Status semantic-release Dependabot Status

When writing a GraphQL schema with the Schema Definition Language, some flexibility, such as adding a deprecationReason to a field is lost. This package implements a custom directive to make it possible to deprecate a field or enum. This is intended for use in Apollo Server that builds the schema with graphql-tools. See the Apollo graphql-tools docs for more information on schema directives.

Usage

npm install graphql-directive-deprecated

Example

import { makeExecutableSchema } from 'graphql-tools';
import { DeprecatedDirective } from 'graphql-directive-deprecated';
 
const typeDefs = `
  directive @deprecated(
    reason: String = "No longer supported"
  ) on FIELD_DEFINITION | ENUM_VALUE
 
  type ExampleType {
    newField: String
    oldField: String @deprecated(reason: "Use newField.")
  }
`;
 
const schema = makeExecutableSchema({
  typeDefs,
  schemaDirectives: {
    deprecated: DeprecatedDirective
  }
});

Package Sidebar

Install

npm i graphql-directive-deprecated

Weekly Downloads

109

Version

3.0.0

License

MIT

Unpacked Size

13.7 kB

Total Files

8

Last publish

Collaborators

  • brandondoran