-
Notifications
You must be signed in to change notification settings - Fork 738
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
Question: How to support feature flags in queries. #900
Comments
Ouch. Yeah I think the idea that your server would roll back to 1.0 once 1.1 had made it that far out the door is not something GraphQL is particularly designed to support. Lemme ping a couple folks. |
One thing I did think of: You can use directives that determine whether to include a fragment. You'd have to write two fragments, one for each version, but then you should be able to use the |
@jbaxleyiii suggests trying something that defines the variable in the query and then uses it in the fragment, like: query($showApproval: Boolean!) {
offers {
...offer
}
}
fragment offer on Offer {
apr
approvalOdds @include(if: $showApproval)
} For what it's worth the spec for |
@john-twigg-ck Does this answer your question? |
@designatednerd (Please tell me I'm wrong, because I hope I am) This falls under the category of "Fragment Variables" which is at best experimental feature in Apollo and GraphQL spec I'm open to other ideas. |
I just tried this out using the fullstack tutorial server that we're using to build the new iOS tutorial, and it looks like this is doable. Here's an example query with a fragment and the passed-in boolean set to And then here's an example where it's set to Does that help? |
I am going to close this out since there is an example of what @john-twigg-ck has requested provided. John, if you have further questions here, please feel free to reopen. Anyone else, please open a new issue. Thank you! |
TL;DR
Question: Does anyone have any good methods of supporting Feature Flags for portions of the queries?
Problem:
We're using the apollo-codegen for both iOS and Android.
There is a tight coupling between the client and the server with respect to the schema.
Example:
One option is to have a highly dynamic schema registry system on the server so as to not allow rollbacks. Let's table that idea for now.
Question: Does anyone have any good methods of supporting Feature Flags for portions of the queries?
Note: I know you can pass in parameters to switch off parts of the query but they don't work with fragments as there's no parameterized fragments ex:
@skip(if: Boolean)
doesn't work in fragmentsIdeal Example might be
Challenges
The text was updated successfully, but these errors were encountered: