Closed tigloo closed 6 months ago
Hi! Thanks for the issue.
You can see a direct usage in this extension where the ref is defined with a wrapper value (MutableValue
, but can be anything) and we set de value like this. The MutableValue
will change for every request since the ref where it is saved is a ScopedRef.local
.
I believe some of the complete examples do something like this for user or token data.
This works, thanks!
I'm building a GraphQL backend using Leto. Requests are authenticated using bearer tokens. The bearer token contains information about the client, for which I need to fetch context data (such as a user object, RBAC information) from the database.
I would like to add a request middleware that stores this information to the request context so that it only needs to be retrieved once, is stored in memory and every handler in the request pipeline can access it - essentially a Map<String,dynamic> that I could freely populate in Ctx.
Does something like this exist? Or an alternative method to achieve this?