Search code examples
amazon-web-servicesaws-lambdaamazon-dynamodbaws-amplifyaws-appsync

AWS Amplify - Pipeline Resolvers vs Lambda Resolvers


When you need to access multiple resources (eg different DynamoDB tables) from a single custom gql operation using AWS Amplify, why would you use pipeline resolvers over lambda resolvers, and vice versa? From reading around, there seems to be very little information regarding the advantages/disadvantages of each approach, as well as use cases where one might be better than the other.

I've read that debugging pipeline resolvers is a nightmare because you can't print/console.log, so if true, that is one huge downside of pipeline resolvers and a reason to use lambdas instead...


Solution

  • Some thoughts (though not exhaustive):

    1. AppSync Pipeline Resolvers do not incur the added cost of a Lambda function
    2. Pipeline Resolvers may be faster, since they don't have to make the extra hop to Lambda (though you should test yourself to confirm)
    3. Lambda may provide a more familiar programming model to you, depending on your experience.
    4. Lambda may also allow you to perform other, more complex operations that cannot be achieved by VTL in AppSync.

    That said, you don't necessarily need pipeline resolvers to access multiple data sources; you can set up multiple data sources with multiple resolvers that can be executed in the same request.

    You might also want to look at https://github.com/serverless/serverless-graphql/issues/248 which contains an interesting discussion on the advantages and disadvantages of using multiple DynamoDB tables behind an AppSync API.