Open naedx opened 3 months ago
You can workaround this limitation by creating a custom mutation that has the desired input or overrides the values for updatesCount
and completed
. Then scope the auth rules to disallow create through the auto-generated create mutation.
https://docs.amplify.aws/react/build-a-backend/data/custom-business-logic/
Describe the feature you'd like to request
Given the following schema:
I would like to be able to specify an initial value for specific fields. I want
Todo.updatesCount
to always have the initial value of0
andTodo.completed
to have an initial value offalse
.Describe the solution you'd like
I would like to be able to set the initial value with
.initial(val: any)
.Describe alternatives you've considered
An alternative is to set the default value and then define a restrictive
input createTodoInput
that does not contain the value. Since the user cannot submit the value the default value is always used. This is subject to the user's permission to set the value.Additional context
The values for
.default()
are set in theinit
pipeline resolver:...which are then superceded by user values when merged in:
A simple implementation for
.initial()
could store values as$ctx.stash.initialValues
and merge them in on top of user values. However, this approach would be subject to the user's authorization allowing them to set these values.A more complete implementation would set these values separately from the user submitted values. This would allow initial values to be set even if the user does not have write permissions on those fields.
Is this something that you'd be interested in working on?
Would this feature include a breaking change?