zCore
zCore
CC#
Created by zCore on 2/4/2023 in #help
❔ Strawberry Shake Prevent Null Serialization (JSON)
1. Write a mutation with optional parameters, which map to optional parameters.
mutation Foo(bar: Int, baz: Int) {
theThing(bar: $bar, baz: $baz {
id
# etc...
}
}
mutation Foo(bar: Int, baz: Int) {
theThing(bar: $bar, baz: $baz {
id
# etc...
}
}
2. Call the muation with null on one parameter
johnDoeClient.Foo.ExecuteAsync(3, null);
johnDoeClient.Foo.ExecuteAsync(3, null);
3. The resulting json for the parameters will be
{
"bar": 3,
"baz": null
}
{
"bar": 3,
"baz": null
}
Now in my case the server actually expects this value to be not null and null is representing optional in this case. Leading the null being serialized to an exception comming from the server complaining. Is there any way to tell Strawberry Shake to not serialize null?
2 replies