The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development. This plugin provides functionality for the API category, allowing for the creation and management of GraphQL and REST based backends for your amplify project.
Use-Case:
Users should be able to create records and the status filed should populate with default value. The restriction is that users, should not be able to pass or update the status value.
The above auth rules are failing with "Unauthorized on [status]" error.
Describe the solution you'd like
To be able to populate the default value to status filed without giving create permission
Describe alternatives you've considered
Current work around:
Override Amplify-generated resolvers to update the Mutation.createTodo.init.2.req.vtl resolver to return unauthorized if id value is passed
## [Start] Setting "status" to default value of "test". **
#if( $util.isNull($context.args.input.status))
$util.qr($context.args.input.put("status", $util.defaultIfNull($ctx.args.input.status, "test")))
#else
$util.unauthorized()
#end
## [End] Setting "status" to default value of "test". **
{}
And also adding "status" to ownerAllowedFields0 in Mutation.createClaim.auth.1.req.vtl
Describe the feature you'd like to request
Sample Schema
Use-Case: Users should be able to create records and the status filed should populate with default value. The restriction is that users, should not be able to pass or update the status value.
The above auth rules are failing with "Unauthorized on [status]" error.
Describe the solution you'd like
To be able to populate the default value to status filed without giving create permission
Describe alternatives you've considered
Current work around: Override Amplify-generated resolvers to update the
Mutation.createTodo.init.2.req.vtl
resolver to return unauthorized if id value is passedAnd also adding "status" to
ownerAllowedFields0
inMutation.createClaim.auth.1.req.vtl
Additional context
Similar Github Issue: 9846
Is this something that you'd be interested in working on?
Would this feature include a breaking change?