From 311c4dceed3713b799ad958952178f2d3fd6e971 Mon Sep 17 00:00:00 2001 From: Hyeseong Kim <cometkim.kr@gmail.com> Date: Mon, 9 Sep 2019 06:10:00 +0900 Subject: [PATCH] Update README.md, add usage with ESLint. --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 99924cf..3f6b5c8 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,28 @@ module.exports = { - `autoFix`: (`boolean?`) Enable auto-fixing static queries with generated types. +## ESLint + +You can use the extracted schema file for [eslint-plugin-graphql](https://github.com/apollographql/eslint-plugin-graphql)! + +```js +// In a file called .eslintrc.js +module.exports = { + rules: { + 'graphql/template-strings': ['error', { + env: 'relay', + schemaJsonFilepath: `${__dirname}/.cache/caches/gatsby-plugin-typegen/schema.json`, + tagName: 'graphql', + }], + }, + plugins: [ + 'graphql' + ] +}; +``` + +You may get error for first time because schema is not extracted in your `.cache` dir yet. + ## Acknowledgements - [gatsby-plugin-extract-code](https://github.com/NickyMeuleman/gatsby-plugin-extract-schema) -- GitLab