-
Notifications
You must be signed in to change notification settings - Fork 221
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
Prepared queries without known variables #277
Comments
Thanks for opening the issue and continuing the discussion on this topic. In fact, I already did a few experiments in this area after #195. It is a bit non-trivial to add this feature, but not impossible :) One of the unclear points (and I would say the most important one) is how to handle the variables that might influence complexity. For example: query Foo($lim: Int!) {
users(limit: $lim) {
id
name
}
} In absence of variables, If we consider the subset of query reducers that are currently available out-of-the-box, then |
Yes, that makes sense--I'm not surprised you already had this idea! Variables show up in two places: arguments to fields, and arguments to directives. I think the least API-breaking change is probably extending If that was the main change and Another option is to introduce another type of reducer that runs at preparation time instead of execution time and doesn't have access to variable values (only their types). This might be less compelling. |
Updated #281 |
Fixed in #281 |
I'd like to be able to prepare (and ideally, run query reducers over) queries that incorporate variables before I actually have values for the variables.
For example, I'd like to prepare a query that requires a
$userId
variable, then subsequently execute that prepared query for any user ID passed in thevariables
.The main use case is to support efficient execution[1] of persisted queries. Sangria's existing Prepared Query support is great, but requires that variables are known at preparation time.
Combined with #195, Sangria's support for prepared/persisted queries would be great.
What do you think? The include/skip (and custom?) directives would need to be applied after variables are known, but I think that's the main hiccup.
[1] I'm generating implementations to fulfill GraphQL queries dynamically, so it would be much more efficient if we did this once per query (without variables filled in) instead of on every request.
The text was updated successfully, but these errors were encountered: