Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Context is built every time the module is imported #294

Closed
iagomelanias opened this issue Jan 27, 2019 · 1 comment
Closed

[Bug] Context is built every time the module is imported #294

iagomelanias opened this issue Jan 27, 2019 · 1 comment
Labels
bug Something isn't working

Comments

@iagomelanias
Copy link

In this tutorial, there is a part where we use GraphQL Modules to build the currentUser context. The recommendation is to create a AuthModule and import it in every module we need to authenticate the user. But... there is a problem.

Every time we import a module into another module, the context is built. So, if we are making DB queries, we're going to make 3, 4, 5, db calls in every request.

A workaround is to create a service using ProviderScope.Session and store the user data in the class property and use it if exists. Is this the expected behavior?

@ardatan
Copy link
Collaborator

ardatan commented Feb 22, 2019

Yes, you're right. Context was built async for each module recursively before. But now we changed it and it is done using a sync iteration.
And for your case, it must be fixed in the latest version. Could you check and let me know if it works correctly.

@ardatan ardatan added bug Something isn't working enhancement labels Feb 22, 2019
@ardatan ardatan closed this as completed Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants