0
votes

I'm complete newbie to AWS. I have appsync models, queries and mutations created by amplify and use DynamoDB. I need to add new timestamp field to DynamoDB in case one specific field has been updated. The only way I found should be Lambda function and use this function as Custom Resolver for mutation UpdateTask. So I created it (it basically just checks if the specific field has been updated and if so, it will set updateXY to current timestamp. I return the changed object). The problem is if I do update no change happens in DynamoDB and no error is returned from Appsync. Can anyone help me, please?

1
Unfortunately, I don't know off the top of my head, but if no one answers here, you can try asking in the Discord: discord.com/invite/jWVbPfC People are usually pretty helpful, and employees on the project hang out there and ask questions.Jim J
@JimJ Thanks a lot, I will try to ask thereGeorge
Please share with us details about how you configured your custom resolver and how your client app is trying to invoke it. General guidance about creation of lambda resolver can be found at docs.aws.amazon.com/appsync/latest/devguide/…Milan Gatyas

1 Answers

0
votes

AppSync works by mapping fields in a GraphQL selection set to resolvers that do something with them. If you've overwritten the default resolver, then you aren't talking to DynamoDB anymore. Returning the value without saving/reading anything from DynamoDB won't have the effect you want. Instead, you'll want to interact with DynamoDB from your Lambda resolver.

For an example of a NodeJS-based Lambda resolver that interacts with DynamoDB directly, checkout this blog:

GraphQL API using Serverless + AWS AppSync + DynamoDB + Lambda resolvers + Cognito. [Part 3]. Note in particular how the functions include DynamoDB utilities:

const { insertOrReplace } = require('./../../util/dynamo/operations');

etc.