How can I inject dependency in request scope?
See original GitHub issueHello, thanks for great library!
I need to inject scoped dependency in my mutation. For example:
services.AddScoped<IUsersWriteService, UsersWriteService>();
...
public async Task<User> RegisterUserAsync(
string name,
string email,
string password)
{
var salt = PasswordUtility.GenerateSalt();
var user = new User
{
Email = email,
Name = name,
Password = PasswordUtility.Encrypt(password, salt),
Salt = salt
};
// inject usersWriteService
return await usersWriteService.CreateUserAsync(user)
.ConfigureAwait(false);
}
How can I do that?
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
How to inject request scoped bean? - spring boot
You need the proxyMode to boot the app with UICtx dependency injected, e.g. define @Component @Scope(value = WebApplicationContext.
Read more >Injection scopes | NestJS - A progressive Node.js framework
The REQUEST scope bubbles up the injection chain. ... Transient-scoped dependencies don't follow that pattern. If a singleton-scoped DogsService injects a ...
Read more >Chapter 5. Scope: a fresh breath of state - Dependency Injection
The real power of scope is that it lets you model the state of your objects declaratively. By telling the injector that a...
Read more >Guice Scopes: Everything They Don't Tell You
In dependency injection frameworks, a scope determines when an injected object will be reused. The most common scope is a Singleton – the ......
Read more >Dependency Injection Scope : r/dotnet
Dependency Injection Scope. I'm having a hard time understanding the scoped instance. I'm comfortable with transient and singleton.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Dolfik1 you should probably wait for the final 0.4.0 since we are currently working on data loaders in the 0.4.0 which is a major change in the execution engine.
So, the previews could still have some issues. I think we will ship the final 0.4.0 at the end of this week.
Hi,
that is actually a bug in the current Version. I have fixed that in my local branch and think that the fix will roll out on Sunday evening. I will get back to you as soon a we have released the next Version.