facebook / facebook/relay

False positive from unused variables validator when query variable is only used in object literal passed to @arguments

Open
#4,932 2 comments 0 reactions 0 assignees View on GitHub
shared with relay team
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

If I have a query like this:
```graphql
query TestQuery($foo: String!) {
...TestFragment @arguments(input: { foo: $foo })
}
```
I get an error like: "Variable `$foo` is never used in operation `TestQuery`"

However if I use that variable in another fragment without the object literal, I get no error and it compiles happily.

```graphql
query TestQuery($foo: String!) {
...TestFragment @arguments(input: { foo: $foo })
...TestTwoFragment @arguments(foo: $foo)
}
```

Is this a bug in the unused variables validator?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.