Table of Contents
Automatically generate a GraphQL Shield from your GraphQL Schema(or type definitions and resolvers).
npm install graphql-shield-generator
yarn add graphql-shield-generator
- Don't forget to star this repo 😉
import { generateGraphqlShield } from 'graphql-shield-generator';
await generateGraphqlShield({
schema,
options: {
outputDir: './permissions',
fileName: 'shield',
extension: 'js',
moduleSystem: "CommonJS"
},
});
// or
await generateGraphqlShield({
schema: { typeDefs, resolvers },
options: {
outputDir: './permissions',
fileName: 'shield',
extension: 'ts',
moduleSystem: "ES modules"
},
});
Generates a GraphQL Shield.
Property | Required | Default | Description |
---|---|---|---|
outputDir | false | current directory | Directory that shield will be placed in |
fileName | false | 'shield' | File name of the generated shield |
extension | false | 'js' | File extension of the generated shield |
moduleSystem | false | 'CommonJS' | Module system of the generated shield |
We are always looking for people to help us grow graphql-shield-generator
! If you have an issue, feature request, or pull request, let us know!