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

DataLoader Dependency Injection Support #966

Merged
merged 7 commits into from
Aug 7, 2019

Conversation

michaelstaib
Copy link
Member

@michaelstaib michaelstaib commented Aug 7, 2019

The DataLoader could already resolve dependencies from the dependency injection container. With this change it is now possible to register a DataLoader with the standard dependency injection container. This enables referencing DataLoaders through interfaces.

Here is how we can now register a DataLoader:

services.AddDataLoader<IMyDataLoader, MyDataLoader>();
services.AddDataLoader<MyDataLoader>();
services.AddDataLoader<IMyDataLoader>(s => ....);

The DataLoaderRegistry is automatically registered when using this.

On the resolver side I can now resolve my DataLoader through an interface:

public async Task<string> ResolveSomething(IMyDataLoader dataLoader) 
{

}

I also do not need to use the [DataLoader] attribute I the interface implements IDataLoader.

Fixes #926

@michaelstaib michaelstaib self-assigned this Aug 7, 2019
@michaelstaib michaelstaib added this to the 10.0.0 milestone Aug 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wire up class data loader by interface.
1 participant