AppSync resolver to Aurora Serverless - '$id' inserting as string

0

Hi,

I'm trying to follow the tutorial at: https://docs.aws.amazon.com/appsync/latest/devguide/tutorial-rds-resolvers.html

I followed the docs closely, but in my input resolver, the '$id' argument is being inserted as '$id' into the table and not a proper ID value like '8b9afc0a-6d07-4b7b-b504-aff44ccac392'.

{
"version": "2018-05-29",
"statements": [
"insert into Test VALUES ('$id', '$ctx.args.input.testValue')",
"select * from Test WHERE id = '$id'"
]
}

As a test, I tried '$util.autoId()' which did give me a proper ID value, but then the select * statement broke.

Any ideas?

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

Are you doing the util.autoId outside the statement block in the following manner? This will generate the id variable that will be set inside the statements.

#set($id=$utils.autoId())
{
    "version": "2018-05-29",
    "statements": [
        "insert into Pets VALUES ('$id', '$ctx.args.input.type', $ctx.args.input.price)",
        "select * from Pets WHERE id = '$id'"
    ]
}

Edited by: Ionut@AWS on Feb 21, 2019 2:08 PM

답변함 5년 전
0

Thank you!

Yup, it's right there in the sample, the darker font in italics made it blend in. Working now :)

Rashad
답변함 5년 전

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

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

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

관련 콘텐츠