14

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?

user3376065
  • 1,137
  • 1
  • 13
  • 31
  • 1
    I'm in the process of scrubbing our docs and replacing `$context` with `$ctx` for consistency. I'll add a note to the [Resolver Mapping page](https://docs.aws.amazon.com/appsync/latest/devguide/resolver-context-reference.html) explaining that `$ctx` is an alias. Sorry for the confusion. – Rohan Deshpande Mar 19 '19 at 15:53

1 Answers1

27

(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.

Rohan Deshpande
  • 3,535
  • 1
  • 26
  • 31