oliyh / re-graph

A graphql client for clojurescript and clojure
461 stars 40 forks source link

Queries and Mutations: websockets or HTTP? #48

Closed promesante closed 5 years ago

promesante commented 5 years ago

Hi, Oliver,

After having finished implementing subscriptions in my GraphQL project, queries and mutations implemented beforehand didn't work any longer.

Analyzing the implementation of re-graph, lacinia-pedestal and lacinia, data involved succesfully reached ::send-ws event in internals.cljs. But I have not been able to detect any corresponding event on the server side (lacinia-pedestal).

Then I experimented commenting websocket invocation in ::query and ::mutate events in core.cljs, and the invocation immediately began to work well again.

I have forked re-graph and shared this modification there.

By the way, I have been using re-graph's 0.1.8 version, which I have taken as reference, from which I've performed a branch called 'hn-clj-pedestal-re-frame'.

Your comments and suggestions are more than welcome.

Thanks

Luis https://promesante.github.io/ https://github.com/promesante

oliyh commented 5 years ago

Hi,

THanks for your feedback. You can more simply disable the websocket transport by providing :ws-url nil in the options to re-graph without any code changes needed, see the options documentation in the readme.

Cheers, Oliy

promesante commented 5 years ago

Hi Oliver,

Sure: I had already found out that setting's purpose.

However, besides queries and mutations mentioned above, the application I am coding implements subscriptions as well which, as far as I am understanding, requires websockets on.

That's precisely why I had lost queries and mutations as soon as I had added subscriptions to the application. That's when I had to device the workaround depicted above.

Thanks for your quick reply.

Luis https://promesante.github.io/ https://github.com/promesante

loomis commented 4 years ago

@oliyh I've recently run into this problem as well. Just to be sure, the recommended solution in this case is to define two instances for the same GraphQL server: one with :ws-url set to nil for query/mutation requests and a second instance for subscriptions?

oliyh commented 4 years ago

Hi,

No, you shouldn't have to perform mutations via HTTP, the websocket should handle them just fine. It was my impression that this was an issue with the server side implementation, I am successfully using re-graph to perform queries, subscriptions and mutations all over a single websocket connection.

Hope this helps