I understand that context is what ever name you define in your Lambda functions but when it comes to Appsync resolvers I'm a bit confused. I've seen both $ctx
and $context
being used in AppSync resolvers including in AWS docs. Some of AWS's own code generation tools like AWS Amplify CLI create resolvers that use both in the same code! I can't find anything in the docs explaining this. What's going on here?
(AWS AppSync dev here)
$ctx
and $context
in AWS AppSync refer to the same Resolver Context. We added $ctx
as an alias for $context
to reduce the number of characters users have to type ($ctx
is 50% shorter than $context
!!)
Choosing $context
or $ctx
is a personal preference. I prefer $ctx
when I'm authoring AWS AppSync resolvers.