Skip to content

Trouble with .graphqlconfig / bad config validation / questions #85

@lydell

Description

@lydell

Sorry for bundling several things into one issue. I initally had just one problem, but when diagnosing it things snowballed.

TL;DR: This plugin works super well, just need to look over config validation in general .)

Here's the test repo: https://github.com/lydell/eslint-plugin-graphql-bug

graphql/named-operations .graphqlconfig problem

I tried switching from schemaJson: require("./schema.json") to using .graphqlconfig. This worked well for the graphql/template-strings rule, but I got trouble with the graphql/named-operations rule.

Using .graphqlconfig it looks as if no additional config is need for the graphql/named-operations rule in .eslintrc.js. So I tried this:

"graphql/named-operations": "error",

But then nothing is reported. This works, though:

"graphql/named-operations": ["error", {}],

graphql/capitalized-type-name .graphqlconfig problem

Same thing here. It looks as if this should be enough:

"graphql/capitalized-type-name": "error",

This results in a validation error:

"graphql/capitalized-type-name": ["error", {}],
Configuration for rule "graphql/capitalized-type-name" is invalid:
  Value "[object Object]" should have required property '.schemaJson'.
  Value "[object Object]" should have required property '.schemaJsonFilepath'.
  Value "[object Object]" should have required property '.schemaString'.
  Value "[object Object]" should match exactly one schema in oneOf.

I couldn't get this rule to work .graphqlconfig.

Questions

Diagnosing the above problems and looking at the other rules, I stumbled upon some questions:

  • Why does graphql/named-operations require a schema?
  • Why does graphql/capitalized-type-name require a schema?
  • Why does graphql/required-fields let you specify env?
    • It seems to be optional, so what's the default?
  • Is env required for graphql/template-strings? It does not seem so when I
    tested. What's the default?

Other minor config validation quirks

They're all described in https://github.com/lydell/eslint-plugin-graphql-bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions