When using AWS Amplify with a dynamodb backend, it's possible to update the AppSync schema and resolvers by modifying the files locally and then executing amplify push
.
I'm using RDS (added it with amplify api add-graphql-datasource
as described in the documentation). Queries and resolvers are setup in AppSync automatically. When I update the Aurora RDS schema, I run amplify api add-graphql-datasource
again to update queries and resolvers.
But how do I add new queries/mutations and bind them to new resolvers (defined in vtl
files on localhost), using the amplify CLI?
I figured out how to do it by using the AppSync Web console. I modify the schema and create resolvers in AppSync, then use amplify codegen
to update App.ts
, queries.ts
, etc. However, this approach is bad for at least two reasons.
- When working with multiple environments, changes to each environment has to be done manually via the AppSync console, which is difficult for larger projects.
amplify codegen
doesn't update theschema.graphql
file on localhost.- Executing
amplify push
after making changes to AppSync over uses the schema defined on localhost and overwrites the schema defined in the AppSync console. - Custom resolvers in
app/amplify/backend/<backend_name>/resolvers
are not synchronized with AppSync - the stack file is not updated automatically.
Am I going about this the wrong way? Is there a better way of updating schema/resolvers using amplify CLI when using and RDS backend?
Thank you!