How I feel about VTL on any given day
Haha okay, okay. I'm just kiddin' (mostly).
AWS recently announced Direct Lambda Resolvers su...
For further actions, you may consider blocking this person and/or reporting abuse
Thank you Shawn for catching this, it's a treat just to have you actually use this code!
not at all lol, i barely know what i'm doing and was following along just to try to learn about this new feature π
i think the struggle i had was how to use direct lambda resolvers in mutations not just queries. i couldnt figure out how to do it. maybe worth a followup post?
Pfffh, you got it. I'll whip something up for this week.
Did you guys manage to figure this out?
@nxtra , in order to do this for a mutation, you'd set the
typeName: Mutation
andfieldName: yourMutationName
. Query, Mutation and Subscription are really just aType
likeTodo
.The one gotcha is that you can't create a resolver on a mutation that already has one. Example being
createToDo
. Amplify has already created a resolver for it inside CloudFormation. You'll need to either to add@model(mutations: null)
so you can override it or create a custom mutation. I prefer the custom mutation because then I still have access to the autogenerated vtl from Amplify. There are times where the authorization rules that are generated in the response.vtl can still be useful.Thanks for the info! I didn't realize yet that indeed a resolver with that name already exists if you name it like that.
Until now I've been making custom Resolvers with lambda functions as pipeline resolvers. I'll try to convert one to a "no-more-vtl" version using your guide.
I'm confused, I thought the whole point of the Amplify cli was so I wasn't modifying cft's directly?
I'd also say the intent of Amplify is to offer you a core set of services that includes authentication, database, file storage, analytics, managed hosting, deployments, with more and counting.
The services are supposed to make it more accessible and approachable for backend and front-end devs, which on the whole, they absolutely do. They're still growing and figuring things out though and in the meantime, they've given the option of customizing your CFTs when you need to do something off the beaten bath.
It's almost inevitable that you will modify CFTs in the future. Amplify offers a lot out of the box but there are several solutions that they don't offer from the cli.
I followed the above, but now the lambda is no longer invoked and the field that previously had the @function now comes back with a null value; any suggestions as to what may be wrong? Thanks!!
Hey Rich, Iβd have to know more about your project and see your CustomResources.json file
Is there any risk in breaking this when you regenerate code or add other resources with Amplify? Or once you've done this it's stable?
As long as you keep the code in the CustomResources file (or another custom stack) and you make sure to remove the @directive, youβre good.
These days I mostly use amplify for its api/auth/appsync integration and the cli for generating as much code as possible because Iβm lazy ;)
Awesome, thanks!