Fork me on GitHub
#graphql
<
2022-09-22
>
enn20:09:48

Is there a way to pre-process (before resolvers run) all incoming values of a certain type (like inject-scalar-transformers), while having access to the request context?

hlship21:09:16

Not directly; we don't pass the application context to the scalar transformers because they are sometimes used in a context where there is no application context (e.g., default values for fields and query variables).

enn15:09:30

I see, makes sense. Our use case is that we want access to the db in our scalar transformers to translate between stable external IDs and fast db IDs. It would be nice to do this in one place, right now every resolver has to know how to do it

hlship19:09:54

Well, I don't think anything about that would be request specific, so your scalar transformers could be closures over access to your DB. You might want to do some memoization as well.

enn19:09:55

Our database is datomic, so the DB version is request-specific