4.0.3 • Published 10 months ago

graphql-directive-private v4.0.3

Weekly downloads
26
License
MIT
Repository
github
Last release
10 months ago

graphql-directive-private

Fields and Objects marked with @private will be removed from the schema. They will not appear in introspection and they will not be queryable.

Example

import privateDirective from 'graphql-directive-private'

const { privateDirectiveTransform } = privateDirective('private')

const typeDefs = `
  directive @private on OBJECT | FIELD_DEFINITION

  type User @private {
    userId: Int
    post: Post
  }

  type Post {
    postId: Int @private
    user: User
  }

  type Query {
    user: User
    post: Post
  }
  `

let schema = makeExecutableSchema({
  typeDefs
})

schema = privateDirectiveTransform(schema)

const query = `
  query {
    user {
      userId
      post {
        postId
      }
    }
    post {
      postId
      user {
        userId
      }
    }
  }
`
const response = await execute(schema, query)
// response == { data: { post: { postId: null } } }
4.0.1

10 months ago

4.0.0

10 months ago

4.0.3

10 months ago

4.0.2

10 months ago

3.0.2

1 year ago

3.0.0

1 year ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.0

5 years ago