graphql-dotnet / graphql-dotnet/graphql-client

Testable Subscriptions with compatibility for TestServer

Open
#354 13 comments 4 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
648
Forks
136
PR merge metrics
No merged PRs in 30d

Description

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
https://github.com/graphql-dotnet/graphql-client/blob/b366e22af112445452440c2c6c1d9978ecef97cb/src/GraphQL.Client/Websocket/GraphQLHttpWebSocket.cs#L403

My suggestion is to add a new constructor
```
public GraphQLHttpWebSocket(Uri webSocketUri, GraphQLHttpClient client, Func 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.