Replies: 1 comment 1 reply
-
All you could do is to make your DI container context-scoped (example: https://github.com/MichalLytek/type-graphql/tree/master/examples/using-scoped-container) so each request get fresh instance of resolver class with all the injected services and datasources scoped to the context and that can use context to resolve the dependencies. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
Let's say you have a resolver which needs to fetch data from a database. In this scenario I see two options.
However the general approach when using Apollo seems to be implementing a datasource, which would be request-scoped (for cacheing using dataloader etc).
These are passed through the context-object. But can they be injected?
I guess what I am asking if I could use inversify or some other framework to inject datasources into resolvers, instead of relying on the context-object.
Beta Was this translation helpful? Give feedback.
All reactions