Skip to content

Testable Subscriptions with compatibility for TestServer #354

Open
@andreyleskov

Description

@andreyleskov

Hello everybody,

I'm using graphql-dotnet project a lot and would like to thank you for the amazing product you build for the whole .Net community.
My company is building GraphQl-first services and relies a lot on integration testing with TestServer.

graphql-client Queries and Mutations work fine with TestServer because it is possible to pass an IHttpClient instance into GraphQlHttpClient constructor.
But for subscription, there is no way to pass WebSocket from TestServer due to the not-configurable creation of ClientWebSocket at

_clientWebSocket = new ClientWebSocket();

My suggestion is to add a new constructor

    public GraphQLHttpWebSocket(Uri webSocketUri, GraphQLHttpClient client, Func<WebSocket> webSocketFactory)
    

to get better control over WebSocket creation.
It would also allow moving condition compilation logic '#if NETFRAMEWORK' out of the GraphQLHttpWebSocket class later on, making it cleaner.

I see a lot of value in supporting subscriptions for TestServer. Our particular scenario is to issue asynchronous mutations and wait for some delayed effect via subscription.

What do you think about such a suggestion?
If you find this idea worthy, I can prepare a PR for your review and further discussion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions