Skip to content

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

Description

@abstractionnl

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions