Optional values in update mutation #7640
-
Hi, I am using Hasura Cloud( v2.0.8-cloud.3), and I want to use a single mutation to update a table, depending on what specific values the user changes in the app. One requirement is that it would be used both via Graphql and a corresponding REST endpoint, thus preventing rewriting the operation in the client. The mutation is:
and if I pass the following variables:
I get the following error:
Is there a way to configure Hasura to ignore missing variables? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Does the same mutation work in Hasura Console? |
Beta Was this translation helpful? Give feedback.
-
This is due to a change introduced in #704 In short: you should use the parent type as input type, and instead of providing a null value when you wish to omit the field, omit the field from the variable. Example for your mutation: mutation update_property_by_id($id: Int!, $setInput: properties_set_input!) {
update_properties_by_pk(pk_columns: {id: $id}, _set: $setInput}) {
id
address
hidden
valuation
}
} Assuming you only want to update the address field, your variables would then look like this: {
"id": 2,
"setInput": { "address":"6 High St" }
} |
Beta Was this translation helpful? Give feedback.
This is due to a change introduced in #704
In short: you should use the parent type as input type, and instead of providing a null value when you wish to omit the field, omit the field from the variable.
Example for your mutation:
Assuming you only want to update the address field, your variables would then look like this: