oliyh / re-graph

A graphql client for clojurescript and clojure

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support servers which don't allow query or mutation on websocket

oliyh opened this issue · comments

It turns out that some servers by design don't support queries or mutations over websocket, but only via HTTP.

re-graph currently prefers all operations via websocket when available and treats HTTP as a fallback. An option should be exposed to only allow some operations via a particular transport to support these other servers.

This is my conversation with @gklijs on Slack:

gklijs  6 hours ago
Mutations over websocket is a bit of weird one, just like queries. Some servers and clients support them and other don't. And it's often not clear.

oliy  5 hours ago
oh i didn't realise that. i see no reason why queries and mutations couldn't take place over any transport - http, websocket, channels etc

oliy  5 hours ago
graphql is transport agnostic after all

oliy  5 hours ago
websockets should give you lower latency, avoid duplication of authentication etc

oliy  5 hours ago
but regardless of what should be, if you are telling me that some servers only support subs over websocket but that queries and mutations must go via http, then this might be something that re-graph should support

oliy  5 hours ago
this is something i didn't realise and i've spent a long time trying to tell people their servers are wrong :cry:

gklijs  5 hours ago
Yes, that's my opinion as well. But graphql-java and kotlin-graphql see it differently. The crazy thing is the mutation/query is excecuted but the result is never send to the client.. As far as I've seen usages of the appollo client it also seems to use websockets just for subscriptions.

gklijs  5 hours ago
It took me some time what was going wrong when trying out those server libraries as well. It would be great if in time there was a better spec for graphql over websockets, and with that some tools to test server implementations.

gklijs  5 hours ago
I think re-graph does it right, for those other servers I could easily change the code to support multiple endpoints. The guild is also trying to get ownership of the code that contains the Protocol most use.

gklijs  5 hours ago
It's also pretty easy, to make it work with queries and mutations. Micronaut-graphql does support queries and mutations over websockets.

oliy  5 hours ago
The GraphQL spec says virtually nothing about subscriptions, it seems like the defacto standard is Apollo because they do things first

oliy  5 hours ago
It would be a small change in re-graph to add an option to specify which messages go over which transport

gklijs  1 hour ago
Yes, it would be a nice improvement.