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

Testable Subscriptions with compatibility for TestServer #354

Open
andreyleskov opened this issue Jun 26, 2021 · 13 comments
Open

Testable Subscriptions with compatibility for TestServer #354

andreyleskov opened this issue Jun 26, 2021 · 13 comments

Comments

@andreyleskov
Copy link

andreyleskov commented Jun 26, 2021

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.

@rose-a
Copy link
Collaborator

rose-a commented Jun 27, 2021

Hi,

I agree the current setup for integration-testing against a webserver setup is not elegant.
Currently it's spinning up an actual webserver on a free port on the testserver.

I'd love to see an elegant solution to this. Please go ahead and prove your concept in the integration tests project.

@andreyleskov
Copy link
Author

Hi rose-a,

I'm glad you like the idea, will prepare the PR for your review this week.

@rose-a
Copy link
Collaborator

rose-a commented Jun 28, 2021

I'm actually hoping for improved stability on the integration test through this, too (see #161). 😉

@andreyleskov
Copy link
Author

andreyleskov commented Jun 28, 2021

I already spotted this issue locally, not sure about its nature yet. But it happens both for TestServer and the real server.

@andreyleskov
Copy link
Author

Submitted #357

@rose-a
Copy link
Collaborator

rose-a commented Jul 1, 2021

Thanks for your work, I'll try to review this over the weekend...

@andreyleskov
Copy link
Author

andreyleskov commented Jul 24, 2021

@rose-a should I provide more explanations or details to help you out a bit?

@rose-a
Copy link
Collaborator

rose-a commented Jul 27, 2021

I'm really sorry, but I didn't get around to this yet... It's still on my To-Do list though.

@andreyleskov
Copy link
Author

Any updates, @rose-a? One year gone )

@pascal20997
Copy link

I'm facing the same issue. It is very inconvenient not be able to use the GraphQL client properly in the tests. Is there any news?

@alexander-jesner-AP
Copy link

Hi, any update on this one, @rose-a? Proper support for TestServer would be of great benefit for the community.

@PKragelund
Copy link

Any updates on this? 🙏

@rose-a
Copy link
Collaborator

rose-a commented Jul 3, 2024

No updates on this yet, as I am very limited on time myself.
It would certainly help a lot if someone would update the corresponding MR to resolve the merge conflicts though.

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

No branches or pull requests

5 participants