You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
False positive from unused variables validator when query variable is only used in object literal passed to @arguments #4932
I'm not sure if Relay support complex object in @arguments. A snapshot test in the compiler would be helpful for further debugging this.
To take a step back, can TestFragment reference the global variable $foo directly?
(I didn't run the compiler against that, so hopefully it's proper syntax)
You can see what I was trying to achieve which was to hardcode the type and only require the $text as a variable. The workaround is to just have StorySearchQuery argument be the full $query: StorySearchInput! object, but that requires the caller to have to specify the extra arguments that I want to hardcode into this query.
To take a step back, can TestFragment reference the global variable $foo directly?
Possibly, but that doesn't achieve my intent which is for the query to be using a specific type, but the fragment itself is not tied to that specific type, or any other hardcoded fields on the input object.
If complex objects passed to arguments is not supported, then that's that, but in my original example, the second code snippet shows that the compiler passes if I also use the same variable in another simple argument. So I assume that it's only a special case that the unused variables validator does not account for, rather than a limitation in the compiler itself.
Activity
tyao1 commentedon Mar 7, 2025
I'm not sure if Relay support complex object in @arguments. A snapshot test in the compiler would be helpful for further debugging this.
To take a step back, can
TestFragmentreference the global variable$foodirectly?trey-miller commentedon Mar 13, 2025
Thanks. I don't have the Relay project running locally, but a snapshot graphql using the test schema might look like:
(I didn't run the compiler against that, so hopefully it's proper syntax)
You can see what I was trying to achieve which was to hardcode the
typeand only require the$textas a variable. The workaround is to just have StorySearchQuery argument be the full$query: StorySearchInput!object, but that requires the caller to have to specify the extra arguments that I want to hardcode into this query.Possibly, but that doesn't achieve my intent which is for the query to be using a specific
type, but the fragment itself is not tied to that specific type, or any other hardcoded fields on the input object.If complex objects passed to arguments is not supported, then that's that, but in my original example, the second code snippet shows that the compiler passes if I also use the same variable in another simple argument. So I assume that it's only a special case that the unused variables validator does not account for, rather than a limitation in the compiler itself.