Server context 🔑
Setup a basic authentication system in our server through context.
Context is a way of sharing data and functions between resolvers. We'll use context to setup a basic authentication system in our server.
With this we can access the authenticated user in any resolver, and use that to control access to any data.
It's really important to remember one key detail of context. It's re-created for every request. So anything we return in context is restricted to the current request.
This makes it perfect for storing data that's only relevant to the current request, like the authenticated user.
Anything sensetive that should not leak between requests should be accessed through context.