soft column presets during insert/update
See original GitHub issueI’m doing an insert mutation that fails when run with a particular limited role:
{
"errors": [
{
"extensions": {
"path": "$.selectionSet.insert_xs_y_one.args.object.x.data.user_id",
"code": "validation-failed"
},
"message": "field \"user_id\" not found in type: 'xs_insert_input'"
}
]
}
with a particular role.
I’ve verified the permissions – the role is allowed to set the user_id value and the token contains the correct and expected claims.
The mutation should insert into two tables: the mutation object writes to the child table, and this table has an object relationship to a parent table, where the foreign key does include the user_id column. I have tried setting the user_id value on each of the child and parent objects, as well as both, and all of these cases error.
The problem appears to be a “Column Preset” – the column preset in this case is set to X-Hasura-User-Id which is the same value for user_id that is being passed in the mutation. If the column preset is removed, then the mutation works (but of course no longer works if the user_id is not specified in the mutation). If the column preset is left, then the mutation only works if no user_id is specified in the mutation.
I don’t believe this should be the case – the column preset should default a missing value, not prevent a mutation that contains the value from working (and furthermore, the value passes all the permission checks and matches the preset).
Failing configuration:

Working configuration, same as above, without user_id column preset.
Hasura v2.13.2
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)

Top Related StackOverflow Question
FYI, without soft presets, there is no backwards-compatible migration path away from presets. In our org we’ve concluded that we should avoid presets and rely entirely on permissions instead, but we have no easy way of getting rid of our existing presets without breaking the app for existing users.
@tirumaraiselvan If that is true, the documentation is really not clear about this. Here is what the section about column presets (https://hasura.io/docs/1.0/graphql/core/schema/default-values/column-presets.html#column-presets) says – I’ve bolded elements of this that imply these are soft presets, not hard presets.
In fact, the whole section is named “Setting default values for fields using role-based column presets”. The term “default” implies a soft preset, not a hard preset.