apollographql / eslint-plugin-graphql

:vertical_traffic_light: Check your GraphQL query strings against a schema.
https://www.npmjs.com/package/eslint-plugin-graphql
1.21k stars 103 forks source link

Query definition is not executable #272

Open AdrienLemaire opened 4 years ago

AdrienLemaire commented 4 years ago

Maybe related to #227

Do you know how to resolve this issue?

Using eslint-plugin-graphql 3.1.1 and Apollo client 3. The app seems to behave correctly with this implementation, so I expect no eslint error here.

.eslintrc.yml

---
env:
  browser: true
  es6: true
  jest: true
extends:
  - plugin:react-hooks/recommended
  - airbnb-typescript
  - airbnb/hooks
  - plugin:@typescript-eslint/eslint-recommended
  - plugin:@typescript-eslint/recommended
  - plugin:@typescript-eslint/recommended-requiring-type-checking
  # - plugin:jest/recommended
  - prettier  # disable rules that prettier auto-formats
  - prettier/react
  - prettier/@typescript-eslint
globals:
  Atomics: readonly
  SharedArrayBuffer: readonly
parser: '@typescript-eslint/parser'
parserOptions:
  ecmaFeatures:
    jsx: true
  ecmaVersion: 2018
  sourceType: module
  project: ./tsconfig.json
plugins:
  - react
  - '@typescript-eslint'
  - graphql
rules:
  # prop-types generated by babel-plugin-typescript-to-proptypes with webpack
  react/prop-types: 0
  graphql/template-strings:
    - error
    #- env: literal # determine from .graphqlconfig
    - env: apollo
      tagName: gql
      schemaJsonFilepath: ./schema.json
  "@typescript-eslint/no-use-before-define": 0
  # https://github.com/iamturns/eslint-config-airbnb-typescript/issues/98
  "@typescript-eslint/indent": ["error", 2, {}]
AdrienLemaire commented 4 years ago

Ping on this issue @abernix @staylor @kamilkisiela (calling the most recent contributors).

abernix commented 4 years ago

I haven't used this plugin in years, but looking at your screenshot, I can't tell if you have any actual fields defined on that Query extension type or not.

AmauryLiet commented 3 years ago

For everyone passing by and looking for a 5-sec hack: I renamed my schema from schema.graphql to schema.gql so that the linter does not look at it (config eslint --ext .ts,.tsx,.graphql with env: 'literal'). Don't forget to update your .eslintconfig with the new schema path ;)