The Amplify CLI recently added support for deploying Lambda GraphQL resolvers directly from your Amplify environment for your AppSync APIs. Lambd...
For further actions, you may consider blocking this person and/or reporting abuse
Followup: I like to change the name of project/function when follow tutorial, this time, however, I discover if I don't use
function
in lambda name, the cloudformation could not actually create the stack.I went ahead and redo the first part of tutorial, but run into an issue when running
amplify push
after I runamplify update api
(instead ofamplify add api
I had to use update because the api has already been created.)Any pointer would be appreciated!
Hi Nader, few questions:
@model directives
intotype Coin
?updateCoin
, how would I differentiate betweencreateCoin
andupdateCoin
resolvers since they have the same operation?Is it possible to access s3/dynamodb configured in an existing amplify project via @function directive? github.com/aws-amplify/amplify-cli...
It doesn't seem to be possible at the moment. I wonder if we can expect this functionality in future versions.
Hey Nader,
Excellent tutorial. I was following along and use
amplify push
to deploy the Lambda. After I typeY
to "Are you sure you want to continue", I saw the following question and stuck on the last one.Any recommendation? Where can I find the documentation for the Amplify API and its behavior?
Really excited about what AWS Mobile team has build. Please keep up the great work.
This is awesome. There is still one part that I haven't been able to figure out.
How does STORAGE_CURRENCYTABLE_NAME environment variable get created? I've looked at the Github repo, but couldn't find a place where it is defined. I can just see that it is accessed within Lambda code.
I assume it was created through Amplify Console, right?
I think I found it here: console.aws.amazon.com/lambda/home there's a section halfway down for environment variables that you can add. Nader must've made a custom one in the console.
Doing this tutorial and things have changed in the amplify CLI so I'm trying to work around that because I like the tone and pace of these tuts.
When updating function, cannot figure out how to "Select the operations you want to permit for currencytable:" Seems that is deprecated.
If anyone can point me to a fix.
Hi Nader,
Thank you for this post! Most of the tutorials and documentation I find about Lambda resolvers involve creating new queries and mutations to use the Lambdas. However, I think it would be very helpful to use Lambda resolvers on queries and mutations that are generated automatically from the GraphQL schema by Amplify.
For example, let's say I have a schema that defines a Person with a phoneNumber field. Amplify automatically generates getPerson, createPerson, etc. How can I create a lambda resolver that is triggered on createPerson (for example to validate the phoneNumber)?
I tried many different approaches but I keep getting errors, it seems that Amplify doesn't play well with adding to or modifying automatically generated resolvers.
I know I can perform phoneNumber validation inside the VTL resolver, but what if I want to use a Node.js validation library for more concise and thorough data validation for all my default mutations?
Thanks again,
Santiago
Hello Nader Dabit,
Good article from the rest of the articles w.r.t resolving graphql and lamda function. Appreciate it.
After following your steps, I got blocked at the first query step from console as the query is throwing exception Lambda unhandler. Therefore I did not go ahead to complete the application. Where could I go wrong?
Running the query listCoins from console->queries is resulting as below.
if the url 'api.coinlore.com/api/tickers/?star...' is executed from "Postman" client then the result is proper.
{
"data": {
"getCoins": null
},
"errors": [
{
"path": [
"getCoins"
],
"data": null,
"errorType": "Lambda:Unhandled",
"errorInfo": null,
"locations": [
{
"line": 31,
"column": 3,
"sourceName": null
}
],
"message": "SyntaxError: Unexpected token 'export'"
}
]
}
Problem resolved. There was error in the lambda function.
Kindly ignore the query
@dabit3
I've added auth and API. It created the dynamo DB table etc in the cloud. The AWS App sync queries are running fine. I want to create a lambda function to Insert new records in a table.
Tables are already existing how I can add a lambda function to API generated tables?
Would you please guide me or provides steps to Integrate Lamda with GraphQL API generated tables?
Thanks
Hi @dabit3 ,
Nice article. I was able to set up my first Appsync API today. How can we return a custom error messages in a mutation call with lambda resolver?
"currencyfunction-${env}"
nice trick. Are there more variables available inside schema.graphql? Like project name?Thanks
Hey @dabit3 , Do you have an example of how to connect to RDS from Lambda and provision all the resorces (including rds database) with cloudformation/amplify?
Is it possible connect an existing DynamoDB table to noSQL storage for using it with functions?