Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What Does this PR do?.
Adds Dataloader to the server to batch and cache
User
queries.Describe In brief the solution / approach you've gone with.
The approach used here uses Dataloader of which a new instance is created on every new connection.
The Dataloader is then made available using dependency injection mentioned here.
MichalLytek/type-graphql#51 (comment)
Describe alternatives you may have considered
A alternate would have been to add Dataloader to the appContext, but the problem with that is would have been difficult to manage and expand overtime.
Use the dataloader over larger time, use it more as a cache with a different lifecycle than that of the request.
Pros of this approach.
This would mean significantly lesser hits to the database and that's amazing.
** Cons of this approach**
Would be difficult to maintain the lifecycle of the Dataloader and may lead to significant memory leaks and hell.
Additional context / quirks
Add any other context, screenshots, or quirks about the implmentation here.