-
Notifications
You must be signed in to change notification settings - Fork 53
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
Distinguishing between nulls and undefindes in variables #348
Comments
My initial hunch for this is having something similar to this:
...which would make all variables in the operation modelled as Thoughts? |
I think that could work. It would have to be nullables all way down to cover our concrete use case, where the nullable fields are on a deeper type.
If the generated type is something like (for some new schema, not the one above)
I think usage would be a bit more ergonomic, i.e.
compared to using
I'm not sure how this interacts with #349. Would all of the GraphQL nullable fields in the schema assets file be modeled as |
@zth I'd like to join this discussion. AFAIK, the option type for the nullable field in the mutation input is not distinguishing between input={a: Some(Obj.magic(Js.Nullable.null)), ...} IMHO, it would need to get a type definition as type input = {
a: int // required
b?: Js.Nullable.t<int> // nullable
}
let i0 = {
a: 1,
b: Js.Nullable.null, // null
}
let i1 = {
a: 1,
// undefined
} I guess it lets us modeling both cases of |
I did an implementation intended to solve this here: #426 @mununki @mbirkegaard what do you think? |
Currently nullable variables in mutations and queries become optional on the rescript-relay side.
Suppose there's mutation that looks something like
which edits some thing. According to coerce argument values in the graphql spec, there's a difference between executing
and
However, on the rescript-relay side the generated mutation input has type
This disallows sending an explicit
null
. Settingb: None
when calling the mutation turns it intoundefined
. Our current solution to this problem is to have the resolver for the mutation turnundefined
intonull
depending on the use case.I think my preference is an explicit approach where all nullable variables are of type
Js.Nullable.t<'value>
and handled when serialising, but I understand that may not be ergonomic enough for everyone and that an escape hatch solution like jeddeloh/rescript-apollo-client#27 is prefered.The text was updated successfully, but these errors were encountered: