Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/taylorgoolsby/graphql-directive-private
Fields and Objects marked with @private will not be exposed through the GraphQL API.
https://github.com/taylorgoolsby/graphql-directive-private
cut directive field graphql hide private remove schema sdl
Last synced: 3 months ago
JSON representation
Fields and Objects marked with @private will not be exposed through the GraphQL API.
- Host: GitHub
- URL: https://github.com/taylorgoolsby/graphql-directive-private
- Owner: taylorgoolsby
- License: mit
- Created: 2018-11-21T00:15:02.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-07-05T01:50:25.000Z (over 1 year ago)
- Last Synced: 2024-10-01T16:27:24.002Z (4 months ago)
- Topics: cut, directive, field, graphql, hide, private, remove, schema, sdl
- Language: JavaScript
- Size: 265 KB
- Stars: 3
- Watchers: 1
- Forks: 3
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 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
```js
import privateDirective from 'graphql-directive-private'const { privateDirectiveTransform } = privateDirective('private')
const typeDefs = `
directive @private on OBJECT | FIELD_DEFINITIONtype 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 } } }
```