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

Add example how to use for Clojure. #49

Closed
gklijs opened this issue Sep 8, 2019 · 4 comments
Closed

Add example how to use for Clojure. #49

gklijs opened this issue Sep 8, 2019 · 4 comments

Comments

@gklijs
Copy link

gklijs commented Sep 8, 2019

I tried to use re-graph from Clojure, but could not get it to work. I tried several things, the latest using the 'plain javascript' style.

  (println "data:" data))

(defn init []
  (re-graph/init {:ws-url   "ws://localhost:8888/graphql-ws"
                  :http-url "http://localhost:8888/graphql"})
  (re-graph/query "{all_last_transactions {iban}}" nil on-thing))```
But there doesn't seem to happen much. When I us a key for the init and query it gives an exception: `Host URL cannot be nil`.
@gklijs
Copy link
Author

gklijs commented Sep 9, 2019

I'm busy hacking something together, making it just Clojure to keep it simple.

@oliyh
Copy link
Owner

oliyh commented Sep 9, 2019

Hi @gklijs

You're not doing anything wrong, the code should be identical to cljs.

You're right, it never becomes 'ready' because of a mistake in the creation of the websocket. I should be able to do a new build soon. Thanks for reporting!

@gklijs
Copy link
Author

gklijs commented Sep 10, 2019

Probably not only the creation but also how to send the payload, I copied the bit I needed, and made it clojure ony, and now use

(defn- send-ws
  [ws-connection payload]
  (ws/send-msg ws-connection (json/encode payload)))

to send.
Turned out for my use case, a load generator, it's easier to work directly with on-receive instead of callback.
I will be speaking at GraphQL Summit 30/31 Oktober, mentioning how usefull and easy to use re-graph is.

oliyh added a commit that referenced this issue Sep 10, 2019
oliyh added a commit that referenced this issue Sep 10, 2019
@oliyh
Copy link
Owner

oliyh commented Sep 10, 2019

Hi,

Yes I found that too. I've made this fix and others relating to http in the latest release 0.1.11-SNAPSHOT.

I would agree that for a performance/load test you might be better off using the underlying websocket directly, re-graph adds some indirection and re-frame in clj is also not designed for performance.

Thanks for reporting this and letting me know about the conference - hope it goes well and I'd be interested to watch your talk after if it's going to be online.

Cheers

@oliyh oliyh closed this as completed Sep 10, 2019
@gklijs gklijs changed the title Add example how to us for Clojure. Add example how to use for Clojure. Sep 10, 2019
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

2 participants