Is your feature request related to a problem? Please describe.
Many developers hesitate to use AWS AppSync because of the learning curve of VTL
Describe the solution you'd like
Provide a way for developers to use programing language they are acquainted with in the fields resolvers. In my case, it is Javascript.
You may be able to accomplish this by using a Lambda Resolver where you can use any language supported by Lambda (Java, Go, PowerShell, Node.js, C#, Python, and Ruby code out of the box).
FWIW I recently learned VTL and it was much quicker than expected, especially if you are already familiar with Javascript in your case.
Thanks for bringing this up. You are always able to use lambda resolvers to write logic in the language of your choice. The reason for VTL is that it is much more performant from a latency perspective and is lower cost for you since you do not need to pay for lambda. We are researching alternative options but for now I would recommend using lambda if you have complex business logic and VTL is not working for you. One tip I would give is to create a standard interface that you will pass to all your lambda functions.
For example, make all of your request mapping templates look something like:
{
"Arguments": $util.toJson($ctx.args),
"TypeName": "Query",
"FieldName": "pingLambda",
"Source": $util.toJson($ctx.source),
"Identity": $util.toJson($ctx.identity)
}
Then in your lambda code you can write some lightweight routing code:
const resolvers = {
Query: {
pingLambda: () => {}
},
User: {
socialFriends: () => {}
}
}
const typeResolvers = resolvers[event.TypeName]
const fieldResolver = typeResolvers[event.FieldName]
return await fieldResolver(event)
You can then easily add lambda resolvers and write code in the language of your choice.
@mikeparisstuff May I get an update on ongoing progress for the alternative options?
IMHO latest amplify versions have abstracted so many basic things and yet it allows easy extension by lambdas which open worlds of possibilities, VTL is a very good option for the problem it solves, it is nice to know it and understand if eventually you need to extend it, and hope you don't need to.
Yes, we can close it
Most helpful comment
Thanks for bringing this up. You are always able to use lambda resolvers to write logic in the language of your choice. The reason for VTL is that it is much more performant from a latency perspective and is lower cost for you since you do not need to pay for lambda. We are researching alternative options but for now I would recommend using lambda if you have complex business logic and VTL is not working for you. One tip I would give is to create a standard interface that you will pass to all your lambda functions.
For example, make all of your request mapping templates look something like:
Then in your lambda code you can write some lightweight routing code:
You can then easily add lambda resolvers and write code in the language of your choice.