Search code examples
amazon-web-servicesaws-lambdaaws-appsyncvtlaws-appsync-resolver

Why does AWS AppSync only directly support VTL (Velocity Template Language) for Resolvers?


It seems that you can write Javascript, but only by adding a new Lambda function which adds cost and complexity of the app. I am just curious to know why this is the case, as VTL seems to be much less popular and it is not a language I am familiar with.

Pros/cons of learning VTL vs taking the Lambda javascript (Node.js) route would be useful to get insight on.


Solution

  • You are right, that's why they released support for JavaScript resolvers last year.

    While JavaScript was only supported for Pipeline Resolvers, it has changed last weeks and now it's supported for all types of resolvers:

    https://aws.amazon.com/about-aws/whats-new/2023/08/aws-appsync-javascript-all-resolvers-graphql-apis

    It's important to notice, that they come with a lot of limitations, including:

    • no support for async code
    • no support for try catch
    • no support for some types of loops
    • you cannot import external libs
    • etc.

    It's because AppSync Resolvers are designed to be simple and fast, if you want to use some complicated logic, then you need to stick to AWS Lambda for resolver

    While AWS Lambda is way more powerful and have almost no limitations, it's more expensive (JS resolvers are free) and it adds more latency, because JS resolvers execute in the AppSync itself, instead of using a separate AWS service which is Lambda