Open M1CK431 opened 1 year ago
:up:
🆙 (bis)
A fragment could be used in another .graphql
file, so at least for that rule, operations need to be provided.
Hi @FloEdelmann and thanks for your reply.
Ok I understand for no-unused-fragments
but what about no-unused-variables
?
no-unused-fragments
we need to see overall siblings whether it's used or not somewhere
no-unused-variables
same as above because fragments can contain variables
Ok, so what about a rule dedicated to check unused variables/fragment in a single .gql
file?
what do you want to omit schema or siblings?
also, I guess requires schema
for no-unused-fragments
can be removed, but not for no-unused-variables
, the test failed with context.getRecursiveVariableUsages is not a function
error
I'm in a use case where the schema is very difficult to fetch from the editor while working on the webapp because of complexe authentication process. In addition the schema is updated relatively often so downloading it as a file is not really an option. So my goal is to enforce the maximum number of rules without the schema.
We don't use fragment so often (despite we should probably), however we already discover unused variables in some of our .gql
files that's why I'm interested to enforce that rule.
Hi @B2o5T , hope you are well :) Any news regarding this issue?
For additional context, my use case does have access to the operations (via parserOptions.operations
) but not the schema, similar to the above. The schema is a moving target, and not deterministic enough for use at build-time. We are catching these issues right now at deploy-time (when the schema is known), but the ability to run static checks like no-unused-fragments
without schema would allow us to catch them much earlier, right in the editor.
Issue workflow progress
Progress of the issue based on the Contributor Workflow
Describe the bug
I don't understand why
no-unused-variables
andno-unused-fragments
rules requires GraphQL Schema and Operations?To Reproduce Steps to reproduce the behavior:
Simpy use that rules without providing GraphQL Schema or Operations.
Expected behavior
Abilty to use
no-unused-variables
andno-unused-fragments
rules without defined GraphQL Schema and Operations.Environment:
@graphql-eslint/eslint-plugin
: N/AAdditional context
I'm working on a frontend webapp where the API schema is not easily reachable because of complexe authentication process. In addition, the API is under active development and the schema is often updated so I can't just download the schema one time and forget.
Still, I would like to ensure that no one left unused variables and/or fragments in
.gql
files. I don't understand why this plugin need to know the GraphQL Schema and Operations to check for unused variables and/or fragments in a single.gql
file. Could you please explain?