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

0

if I have a schema that has this

type light{
status: String = 'Off'
}

and a query like this...
getLightStatus(status:String)

and it is call like this
getLightStatus()

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

I have seen this
$util.defaultIfNull()
and
$util.defaultIfNullOrEmpty()

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?

질문됨 5년 전714회 조회
2개 답변
0

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(${context.arguments.events},0) == 1 )

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

답변함 5년 전
0

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

답변함 5년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠