Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add *.graphql support #47

Open
2 tasks
natterstefan opened this issue Jan 28, 2022 · 0 comments
Open
2 tasks

feat: add *.graphql support #47

natterstefan opened this issue Jan 28, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@natterstefan
Copy link
Owner

natterstefan commented Jan 28, 2022

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

@natterstefan natterstefan added the enhancement New feature or request label Jan 28, 2022
@natterstefan natterstefan self-assigned this Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant