0.0.4 • Published 5 years ago
@jfrolich/gatsby-plugin-extract-schema v0.0.4
gatsby-plugin-extract-schema
A Gatsby plugin that extracts your graphql schema to a .json
file.
You can use this file to check your queries against your schema, by using eslint-plugin-graphql.
Install
Extract schema:
npm install --save gatsby-plugin-extract-schema
Use extracted schema:
npm install --save-dev eslint babel-eslint eslint-plugin-graphql
How to use
Edit gatsby-config.js
module.exports = {
plugins: ["gatsby-plugin-extract-schema"]
};
or
{
resolve: "gatsby-plugin-extract-schema",
options: {
dest: `${__dirname}/path/to/schema.json`,
},
},
}
Check queries against schema
Add .eslintrc.js
to the project root
const path = require("path");
module.exports = {
parser: "babel-eslint",
rules: {
"graphql/template-strings": [
"error",
{
env: "relay",
schemaJsonFilepath: path.resolve(__dirname, "./schema.json"),
tagName: "graphql"
}
]
},
plugins: ["graphql"]
};
Big thanks to Kurtis Kemple for all his help!
0.0.4
5 years ago