feat: add *.graphql support
natterstefan opened this issue · 0 comments
natterstefan commented
Feature Request
Support using .graphql
files in your project.
Basic example
/* eslint-disable global-require */
/**
* @type {import('eslint').ESLint.Options}
*/
module.exports = {
extends: [
'eslint-config-ns-ts',
],
plugins: ['graphql']
overrides: [
{
files: ['*.graphql', '.gql'],
rules: {
/**
* Graphql linting
*
* This plugin also lints GraphQL literal files ending on .gql or .graphql.
* In order to do so set env to 'literal' to tell eslint to check these
* files as well.
*/
'graphql/template-strings': [
'error',
{
env: 'apollo',
schemaJson: require('./graphql/schema.json'),
},
{
validators: [
'FieldsOnCorrectTypeRule',
'NoFragmentCyclesRule',
'UniqueOperationNamesRule',
'UniqueArgumentNamesRule',
],
env: 'literal',
schemaJson: require('./graphql/schema.json'),
},
],
'graphql/named-operations': [
'error',
{
env: 'literal',
schemaJson: require('./graphql/schema.json'),
},
],
'graphql/no-deprecated-fields': [
'warn',
{
env: 'literal',
schemaJson: require('./graphql/schema.json'),
},
],
// 'graphql/required-fields': [
// 'error',
// {
// env: 'literal',
// schemaJson: require('./graphql/schema.json'),
// /**
// * ensure that we never miss adding `id` to queries, as this can
// * lead to nasty issues with apollo.
// */
// requiredFields: ['id'],
// },
// ],
},
},
],
}
Tasks
- define how to provide
schemaJson
files (1 and multiple/different ones). - add note that currently only
@apollo/client
code is tested
Notes
- use https://github.com/B2o5T/graphql-eslint instead of https://github.com/apollographql/eslint-plugin-graphql (see notes about Upcoming Deprecation Plans)
- example w/ apollo project: nodkz/example-apollo3@b885992...ecbc76b