How do I use a schema fields default value in a template?


if I have a schema that has this

type light{
status: String = 'Off'

and a query like this...

and it is call like this

how can I use the default value of the status "Off" in the templates (VTL)?

I have seen this

but it looks like I need to supply the default to these function instead of access the value in the schema...or am I missing something?

asked 4 years ago547 views
2 Answers

The short answer is I can't. I removed the default values from the schema and added them to the request resolver using a util function.

Like this:

#if( $util.defaultIfNull(${},0) == 1 )

The defaultIfNull will test to see if the value events param has a value and if not set it to 0

answered 4 years ago

This behavior is not yet supported and, as of writing, resolver templates cannot access default values from the schema.

answered 4 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions