-
Notifications
You must be signed in to change notification settings - Fork 701
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
Differentiate between explicit and implicit nil fields #66
Comments
As mentioned on Slack, we used to generate initializers for all permutations of optional variables, so we could differentiate between not providing a value for a variable and providing I don't see a way to get both strict typing and the ability to pass in |
I think exposing an initializer with an untyped
|
That's clever! But without language support for automatic wrapping (like you get for optionals), I agree it's too cumbersome. I was thinking we could also expose a subscript or method to set var event = EventCreateInput(content: "contentId")
event["reaction"] = NSNull()
// or maybe something like:
event.nullify("reaction") |
This looks awesome! I like |
Yes, that should work. I also like |
Would this be enough?
|
I think you'd want the type of the subscript to be |
Yes and yes ;) |
@fruitcoder: Going to close this issue, because I just merged what seems like a very clean solution! The generated input objects now have properties of nested optional types when the object fields are optional. That means we can differentiate between |
I have mutation that takes a
EventCreateInput
where every field is optional. Setting different fields and the combination thereof provides the graphql server with the information to run the mutation. But the problem is that providingnull
for certain fields causes the server to behave differently from not including the field at all.Example:
The events are interactions with an item. Multiple events are sent for a single item. When providing an id for
reaction
the server registers the reaction with that item. To remove the reaction from that item I need to give this input to the mutation:But this is not possible since we cannot differentiate between a parameter being explicitly set to
nil
and one being left out when creatingEventCreateInput
so it takes the default value ofnil
.The text was updated successfully, but these errors were encountered: