-
Notifications
You must be signed in to change notification settings - Fork 48
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
Don't check variant exhaustiveness if a fallback variant is provided #795
Don't check variant exhaustiveness if a fallback variant is provided #795
Conversation
✅ Deploy Preview for cynic-querygen-web canceled.
|
I think the change in this PR does make sense. It seems a reasonable default - quite consistent with how exhaustiveness is handled in the Though I wonder if we should be adding a What do you think? |
@obmarg sounds good! Would you like me to add the attribute in this PR? I can do that, just wondering if it should be a separate change. |
However, now that I think about it, having exhaustiveness checking enabled is a sane default for enums. It's what one wants most of the time, I think. No? |
It's definitely the best default when you don't have a fallback. When you do have a fallback.... I am not sure. I can see an argument for both approaches there. The tactic I've used in the past has been to ensure that cynic continues compiling in the face of changes, unless those changes would break the runtime queries. That was the line of reasoning I used for suggesting But at the same time, yes - exhaustiveness checking on enums does seem like a thing most users would want... Not to abdicate my responsibilities. but I might leave this decision up to you. It needs to be configurable one way or the other - but it's your feature so whatever makes the most sense to you.
Yeah, this PR is fine unless you particularly want to make another one. I can also get round to it myself (eventually) if you've not got the time - let me know if so. |
a064b9e
to
149c776
Compare
@obmarg thank you for your guidance, this makes sense! I went ahead and added one more commit that adds a The rule is as follows: What do you think? |
Nice one @jakubadamw - that all seems pretty sensible. Thanks for doing that. |
Released in v3.4.0 |
Why are we making this change?
Sometimes it is useful to capture the name of a variant of a GraphQL enum into cynic's fallback variant without enumerating all the existing variants in the cynic-mapped Rust enum. In such case one may want to opt out of exhaustiveness.
What effects does this change have?
Enums that contain a fallback variant are excluded from the exhaustiveness check.
I am not sure about this change – perhaps it should be controlled by another
cynic(non_exhaustive)
attribute.