mirumee / ariadne

Python library for implementing GraphQL servers using schema-first approach.
https://ariadnegraphql.org
BSD 3-Clause "New" or "Revised" License
2.21k stars 179 forks source link

Extend WS protocol testing. #965

Closed dvg-vitol closed 1 year ago

dvg-vitol commented 1 year ago

Testing of the recent graphql-ws protocol support issue is limited.

A concrete example is whilst we have test_query_can_be_executed_using_websocket_connection_graphql_transport_ws, we do not have a mutation equivalent.

This makes it hard to discern between problems in ariadne, in understanding, or with use of ariadne.

As you may be able to read between the lines, I am unsuccessfully trying to serve websocket borne mutations. I am not confident that this is because of some error implementing the web socket protocol, but without any tests or examples I am also not confident that this is currently possible.

rafalp commented 1 year ago

@pigletto does this seem any way related to your area of interest in websockets? Would you be able to help here with extra tests?

pigletto commented 1 year ago

@rafalp @dvg-vitol I've added a simple test on my fork, please have a look if something like this is enough: https://github.com/mirumee/ariadne/commit/a9b2f36baa0600bde980f33f65f426ac54b26dd9

I don't think there is any real difference between using queries and mutations over WebSockets. The only issue might be if one needs to upload files - in this case, it seems to me that it is not possible as there is no multipart upload for WebSockets.

dvg-vitol commented 1 year ago

Works well for me. I'd have found this reassuring in development. With exploration of graphql potentially cohabiting schema, client, and server simultaneously, light guidance like this is very helpful! I'd worked through my errors on the testquery[...]websocket logic, and the further inclusion means the next victim won't need to make that deduction.

rafalp commented 1 year ago

We now have test that verifies that mutations are callable over the websocket. Thank you @pigletto