Keep your graphql schema up-to-date with gulp! Made for gulp 3
- Attempts to generate a graphql schema from
schema.js
- Can output both
schema.json
andschema.graphql
npm install gulp-graphql --save-dev
Example gulpfile.babel.js
:
import gulp from 'gulp';
import schema from 'gulp-graphql';
gulp.task("schema", () => {
console.log("Generating graphql schema...");
return gulp.src("src/data/schema.js")
.pipe(schema({
json: true,
graphql: false,
}))
.on('error', console.log)
.pipe(gulp.dest("src/data"))
.pipe(gulp.dest("dist/data"));
});
gulp.task('watch-schema', () => {
gulp.watch("src/data/schema.js", [ 'schema' ]);
});
gulp.task("default", ["schema"]);
json
(optional) (default:true
)- Generate a graphql schema from your
schema.js
and output toschema.json
- Generate a graphql schema from your
graphql
(optional) (default:true
)- Output schema as a readable
schema.graphql
file
- Output schema as a readable
fileName
(optional) (default:schema
)- Base name for your schema file, no extension
indentation
(optional) (default:2
)- Takes an
Integer
for indentation spaces ofschema.json
- Takes an
graphqlPath
(optional)- Override for where to find
graphql
module.
- Override for where to find
Passing in graphql
via init is a hack that I'm not thrilled about but seems to work.
- No longer needs to be initialized!
- Attempts to find modules
graphql
andgraphql/utitlites
on its own.
- Generates graphql
schema.json
andschema.graphql
files w/ tests.
MIT License