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

Invalid configuration rule for "graphql/template-strings" #283

Open kryptonat opened 4 years ago

kryptonat commented 4 years ago

Hi, I'm getting an unexpected validation rule error from giving an array of desired validators as per instructions. I had no issues with this configuration for graphql@1.10.9 and eslint-plugin-graphql@3.1.1 but don't see why it wouldn't work for the following package versions either.

module.exports = {
  parser: "babel-eslint",
  rules: {
    'graphql/template-strings': [
      'error',
      {
        env: 'apollo',
        validators: ['FieldsOnCorrectType'],
      },
    ],
  },
  plugins: ['graphql']
};

is giving the following error

Configuration for rule "graphql/template-strings" is invalid:
    Value "FieldsOnCorrectType" should be equal to one of the allowed values.
    Value ["FieldsOnCorrectType"] should be equal to one of the allowed values.
    Value ["FieldsOnCorrectType"] should match exactly one schema in oneOf.

Versions

eslint-plugin-graphql@4.0.0 graphql@15.3.0

OlfaKaroui commented 3 years ago

Since you're using graphql 15, I believe that you have to add "Rule" suffix to your validators. So FieldsOnCorrectType should become FieldsOnCorrectTypeRule

Check this PR for more info : https://github.com/apollographql/eslint-plugin-graphql/pull/281