graphql

enn 2022-09-22T20:05:48.593909Z

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?

hlship 2022-09-22T21:31:16.618129Z

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

enn 2022-09-23T15:36:30.530759Z

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

hlship 2022-09-23T19:17:54.952099Z

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.

enn 2022-09-23T19:19:55.682359Z

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