question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How can I inject dependency in request scope?

See original GitHub issue

Hello, 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:closed
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
michaelstaibcommented, Jul 23, 2018

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

1reaction
michaelstaibcommented, Jul 21, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found