Search code examples
amazon-web-servicesaws-appsyncvtl

VTL macro in AWS Appsync


I'm writing a request resolver for aws appsync, my macro isn't working

I've tried reducing it to its simplest form as shown in the code below, it just returns #addArgs() rather than "test"

#set( $argNames  = {} )

#macro( addArgs)
"test"
#end

#addArgs()
#foreach( $entry in $arguments.entrySet() )
    $!{argNames.put("$entry.key", $entry.value)}
#end

{
"version": "2017-02-28",
"operation": "Invoke",
"payload": {
    "body": {
        "args": $util.toJson($argNames)
    },
    "headers": {
        "Authorization": "$ctx.request.headers.Authorization",
    }
}
}

I expect to get the word "test" when I run the test, but I get #addArgs instead.


Solution

  • Macros are not supported in VTL for AppSync