facebook / facebook/relay

Feature request: global variables whose values are hard coded + `skip_unreachable_node` understanding that

Open
#4,879 1 comment 2 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
19k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

- At Pinterest, we have performance issues for queries with large ASTs. This relates to our backend, and isn't a Relay problem.
- We have a global variable `isAuth`, and frequently do `...AuthFragment @include(if: $isAuth)` or `...UnauthFragment @skip(if: $isAuth)`
- This provides great DevEx, but also results in a query containing both `AuthFragment` and `UnauthFragment`. These queries end up timing out, and causing problems.
- We can work around this by having two queries: `query MyAuthQuery { ...SomeRootFragment @arguments(isAuth: true) }` and vice versa for unauth.
- This is doable, but it also means that we have to use `@arguments` and `@argumentDefinitions` everywhere for

So my feature request is that relay allows you to hard code certain query variables: `query MyAuthQuery($isAuth: Boolean! @hardCodedTo(value: true))` or `MyAuthQuery($isAuth = true)` (though this gets away from GraphQL syntax), and have the `skip_unreachable_node` transform drop the relevant fragments from the normalization AST.

Cheers!

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.