Questions tagged [vtl]

The Velocity Template Language (VTL) is meant to provide the easiest, simplest, and cleanest way to incorporate dynamic content in a web page.

VTL is the Velocity Template Language.

It includes Variables, Properties, Methods, Directives, Macros, and more...

Reference: http://velocity.apache.org/engine/2.0/vtl-reference.html

193 questions
3
votes
1 answer

How to attach response header in VTL template

My application is in serverless framework and I am using vtl template as a lambda resolver. My app stack is AppSync, Lambda on Node JS runtime, Serverless framework and vtl templates. I am trying to figure how I can add custom response headers from…
Arjun
  • 133
  • 1
  • 5
3
votes
1 answer

append for string variable in Apache Velocity Template Language

I want to construct query string in the API Gateway mapping template. I have something like this #foreach($entry in $entries) #set($count = $foreach.count) #set($entriesQueryString = "$!{entriesQueryString}Id=${count}&" #end The idea is to…
Tigran Sahakyan
  • 363
  • 1
  • 5
  • 10
3
votes
0 answers

Add a Unique Constraint to a AppSync Model Attribute

I'm trying to add a a Unique constraint to one of the fields of the my AppSync Model The model is as follows type User @model @key(name: "ByEmailAddress", fields: ["emailAddress"], queryField: "userByEmailAddress") { id: ID! fullName:…
Varun Rathore
  • 7,730
  • 3
  • 27
  • 30
3
votes
4 answers

How can I reuse/import code in vtl appsync resolvers?

I want to avoid duplication of certain declarations in my vtl templates and share them between vtl resolvers. Let's say I have a sample dict in mapping_templates/shared.vtl #set($sample_mappings = { "KEY1": "VALUE1", "KEY2": "KEY2" }) which…
Gilles Major
  • 135
  • 5
3
votes
3 answers

In AWS Resolver Mapping Template, is there any method for removing a field from an object?

I'm writing code for my GraphQL resolvers in AWS AppSync with resolver mapping template. I know that there is a put mehtod that I can use for add a field to input object or any other object. Like this (for example): $util.qr($name.put("firstName",…
Orilious
  • 331
  • 5
  • 16
3
votes
2 answers

Is there a Model.objects.update_or_create() for AWS Appsync using VTL?

I'm using $util.autoId() and would like to know if there is a pattern to do an update_or_create() (similar to the Django one) using VTL or if I should link the Resolver to a Lambda and do the logic in there?
Claudiordgz
  • 3,023
  • 1
  • 21
  • 48
3
votes
1 answer

Velocity Template is not detempletizing when a field inside object is accessed

I've written the below code, which basically needs to print Hello simple Kishore by substituting the values of $string and $value.name inside the template Hello $string $value.name. It substitutes the value of $string however $value.name is never…
Kishore Bandi
  • 5,537
  • 2
  • 31
  • 52
3
votes
1 answer

how to handle nested lists in AWS APIG Mapping Template in VTL

(Here's my Model scheme: { "$schema": "http://json-schema.org/draft-04/schema#", "title": "QuestionsModel", "type": "array", "items": { "type": "object", "properties": { "section_name": { "type": "string" }, "options" : { "type" :…
Carl
  • 2,896
  • 2
  • 32
  • 50
2
votes
3 answers

Velocity (VM) template request parameters: Getting GET variables

How do i access GET variables as passed in the URI in a VM template? This works only when loading the widget URL: $request.get("parameters").get("fav").get(0) I'm looking for a neat solution that works with friendly URLs. Here's my testing…
Cees Timmerman
  • 17,623
  • 11
  • 91
  • 124
2
votes
1 answer

AWS Amplify Graphql Unauthorized Error - Not Authorized to access [...] on type [...]

I have an AWS Amplify App using Cognito auth These are the affected Models/Schemas: type Objective @model id: ID! .. employee: Profile @belongsTo tenant: String } type Profile @model id: ID! .. objectives: [Objective]…
2
votes
2 answers

API Gateway integration response mapping: parse statusCode and body from Step Function output

I want to parse 'statusCode' and 'body' values from API Gateway integration response using VTL and return those as a method response like this: Request status: 201 Response body: {"firstName":"He","lastName":"Man","email":"he.man@eternia.com"} My…
villekr
  • 221
  • 1
  • 3
  • 9
2
votes
0 answers

How to return from a AWS Appsync resolver pipeline without throwing an error

I have a resolver pipeline where I check to see if an item exists. If it does not I want to start a lambda which will create the data. If the queried item exists already I want to return from the pipeline altogether without executing the lambda. It…
2
votes
1 answer

AppSync console is extremely slow to update whenever I edit resolver

Whenever I Edit Resolver in the AppSync console, and save, then execute the corresponding updated query, it keeps showing the previous results. Like, I clicked "Save Resolver" multiple times, clicked the play button to execute query 20 times,…
2
votes
0 answers

How to throw custom error from Velocity template using lambda

In my Lambda I am throwing custom error but from the vtl I am unable to get that when testing in Postman. In the postman I am keep getting message "A custom error was thrown from a mapping template." but I am expecting to get message and object from…
Arjun
  • 133
  • 1
  • 5
2
votes
2 answers

Appsync resolver response template error: Unable to convert to object

I have an appsync velocity response mapping template that is returning the annoying error of "Unable to convert \n \n , \n , \n …
hyprstack
  • 4,043
  • 6
  • 46
  • 89
1 2
3
12 13