graphql-platform
graphql-platform copied to clipboard
Strawberry Shake does not add interfaces of queries as services to DI container
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.