You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have defined a mutation to update an object. _id is a required parameter, everything else is optional. When I send one such query and only set a few of these properties, the context is still populated with the missing fields as soon as our middleware is hit, all of them having null values. We would like to support partial updates, so an input object only containing only the fields the user actually set would be preferred. The current implementation makes it impossible to determine if the user wanted to set a value to null explicitly or chose to not update the missing fields at all.
I tracked the issue down to the InputParser, the missing values seem to be populated here.
The solution you'd like
Allow configuring the input parser to support the desired behavior.
The text was updated successfully, but these errors were encountered:
I created a PR to illustrate the required changes. I also added a simple test for the new behavior but can't get it to run because it's missing some instances of the tested components.
Thats what IOptional is for in HotChocolate. It still follows the GraphQL input coercion but tells you that the value was produced by a default. I am going to close your PR as we will not include it. We can discuss what IOptional is lacking and can improve it.
But IOptional doesn't really solve the issue, does it? As soon as the actual execution of the mutation starts, the input object is already populated with default values the user didn't provide. As far as I understand it there is no way of reproducing the caller's intention.
Product
Hot Chocolate
Is your feature request related to a problem?
I have defined a mutation to update an object. _id is a required parameter, everything else is optional. When I send one such query and only set a few of these properties, the context is still populated with the missing fields as soon as our middleware is hit, all of them having null values. We would like to support partial updates, so an input object only containing only the fields the user actually set would be preferred. The current implementation makes it impossible to determine if the user wanted to set a value to null explicitly or chose to not update the missing fields at all.
I tracked the issue down to the
InputParser
, the missing values seem to be populated here.The solution you'd like
Allow configuring the input parser to support the desired behavior.
The text was updated successfully, but these errors were encountered: