generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 90
Open
Labels
bugSomething isn't workingSomething isn't workinggraphql-transformer-v1p2pending-maintainer-responseIssue is pending a response from the Amplify team.Issue is pending a response from the Amplify team.
Description
How did you install the Amplify CLI?
No response
If applicable, what version of Node.js are you using?
No response
Amplify CLI Version
14.0.1
What operating system are you using?
Ubuntu
Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
No
Describe the bug
Using GraphQL Transformer V1. Adding a field level auth rule for a model makes the given field always be null for mutations. I'm not sure if this is a bug or expected behavior? If it is expected, help me understand why does this happen.
Example of the generated resolver:
TestModel.authField.res.vtl
## [Start] Checking for allowed operations which can return this field **
#set( $operation = $util.defaultIfNull($context.source.operation, "null") )
#if( $operation == "Mutation" )
$util.toJson(null)
#else
$util.toJson($context.source.authField)
#end
## [End] Checking for allowed operations which can return this field **
Expected behavior
The field with auth rule should be returned in the response of Mutations as well.
Reproduction steps
- Use transformer v1
- Add following to the schema
type TestModel
@model
{
id: ID!
authField: String
@auth(
rules: [
{ allow: public, operations: [read] }
]
)
}
- Run codegen
- See how the generated resolver
TestModel.authField.res.vtlalways sets the field to null on Mutations.
Project Identifier
No response
Log output
Details
# Put your logs below this line
Additional information
We should be able to work around this by overwriting the resolvers (https://docs.amplify.aws/gen1/react/tools/cli-legacy/overwrite-customize-resolvers/#overwriting-resolvers)
Before submitting, please confirm:
- I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- I have removed any sensitive information from my code snippets and submission.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggraphql-transformer-v1p2pending-maintainer-responseIssue is pending a response from the Amplify team.Issue is pending a response from the Amplify team.