Possible to reference current values of a record in a mutation? #9071
-
I'm just getting started with Hasura, and I've been loving how easy it is to set up REST endpoints for basic CRUD operations on a Postgres database. I'm building some update mutations which take a bunch of variables to update all of the fields on a given record type. Here's an example:
This works great when you provide values for each of the variables, but I'm not sure how to make it work in situations where you provide a subset of fields and would like to leave the other fields alone. For example, let's say I'm working on a user record where Is it possible to somehow pass the current values of fields on a record as the default value for a mutation variable? I think that would accomplish the desired behavior, but I can't figure out how to do it! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You may like to use Input Types instead of a large list of input parameters for the mutation. |
Beta Was this translation helpful? Give feedback.
-
@evanRetool Here is some additional info to help you build your mutation :
Your would pass the following variables (to just set the account_admin to true and leave other fields untouched):
However, you would see null values in the other fields if you are using nullable variables for those. Hope, the info is sufficient to unblock you. Let us know if you need any additional info. |
Beta Was this translation helpful? Give feedback.
@evanRetool
Hope, you were able to use Input Type to consolidate all the input variables.
Here is some additional info to help you build your mutation :
Your would pass the following variables (to just set the account_admin to true and leave other fields untouched):
However, you would see null values in the other fields if you are using nullable variables for those.
Because, nullable variables for which a val…