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
gefragt vor 5 Jahren334 Aufrufe
2 Antworten
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

beantwortet vor 5 Jahren
0

Thank you!

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

Rashad
beantwortet vor 5 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen