aws-amplify / amplify-cli

The AWS Amplify CLI is a toolchain for simplifying serverless web and mobile development.
Apache License 2.0
2.81k stars 821 forks source link

What is the correct way to handle server-side data verification in AppSync? #2297

Closed ilyador closed 5 years ago

ilyador commented 5 years ago

Let's say I have an app that for some user action they increment a score by 1 point. I must make sure that the user cannot increment the value in the DB by more than 1 at a time.

Using a REST server I'd simply do that in the handling function, however I have no idea where in the AppSync pipeline is the correct place to handle such logic.

amirmishani commented 5 years ago

@ilyador so basically you need Appsync to call a lambda function instead of directly going to the database. Inside your lambda function you can handle custom data and custom logic.

Check out the docs for examples of handling custom data and custom logic.

chrisco512 commented 5 years ago

There's no need to use a lambda for this simple use case. You can simply edit your request mapping template in VTL to increment the value. See: https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-dynamodb-resolvers.html for more info.

attilah commented 5 years ago

Thanks for answering @amirmishani @chrisco255! @ilyador these are your choices, pick what would be the best fit your environment/project.

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels for those types of questions.