Description
Currently nullable variables in mutations and queries become optional on the rescript-relay side.
Suppose there's mutation that looks something like
input MyMytationInput {
id: ID!
a: Int
b: Int
}
myMutation(input: MyMutationInput): string
which edits some thing. According to coerce argument values in the graphql spec, there's a difference between executing
mutation myMutation(input: {
id: "my-id",
a: 7,
b: null
})
and
mutation myMutation(input: {
id: "my-id",
a: 7,
})
However, on the rescript-relay side the generated mutation input has type
type myMutationInput = {
id: string,
a: option<int>
b: option<int>
}
This disallows sending an explicit null
. Setting b: None
when calling the mutation turns it into undefined
. Our current solution to this problem is to have the resolver for the mutation turn undefined
into null
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.