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

Strawberry Shake does not add interfaces of queries as services to DI container #6955

Open
abstractionnl opened this issue Mar 1, 2024 · 0 comments · May be fixed by #7016
Open

Strawberry Shake does not add interfaces of queries as services to DI container #6955

abstractionnl opened this issue Mar 1, 2024 · 0 comments · May be fixed by #7016

Comments

@abstractionnl
Copy link

Product

Strawberry Shake

Is your feature request related to a problem?

If you create any query, there is an interface and a class implementation generated for it. Only the direct class implementation is added to the service collection when using services.AddGraphQLClient(). This means the interface type cannot be used as a dependency on other classes.

A workaround is available, but this needs to be repeated manually for each query type:

services.AddSingleton(sp => sp.GetRequiredService<IGraphQLClient>().GetTaskTypes);

The interface type is needed so it can be mocked in unit tests.

The solution you'd like

Register the generated query interfaces in the service collection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants