0.3.3 • Published 4 years ago

@graphql-reshape/directives v0.3.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

@graphql-reshape/directives

How to install

npm i @graphql-reshape/directives

How to use

  1. Import the directive you would like to use in your schema and using Apollo's makeExecutableSchema() add the directive to the schemaDirectives:

    import { MaskedDirective } from '@graphql-reshape/directives';
    
    const schema = makeExecutableSchema({
      typeDefs,
      schemaDirectives: {
        masked: MaskedDirective
      }
    });
  2. Add the directive schema definition to your schema and use the directive:

    directive @masked(showLast: Int = 4) on FIELD_DEFINITION
    
    type Person {
      name: String!
      dateOfBirth: String! @masked(showLast: 2)
    }

    OR alternatively you can use the @graphql-reshape/cli to apply definitions and directives to your schema with ease.