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
asked 5 years ago325 views
2 Answers
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

answered 5 years ago
0

Thank you!

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

Rashad
answered 5 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