Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rbalicki2 opened this issue Jan 13, 2025 · 1 comment

Comments

@rbalicki2
Copy link
Contributor

  • 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!

@rbalicki2
Copy link
Contributor Author

To add to this, it's actually a bit worse than I mentioned, because we have both $isAuth and $isDesktop variables, so we will have 4x the queries :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant