oliyh / re-graph

A graphql client for clojurescript and clojure
460 stars 39 forks source link

Add note to ::re-graph/query example #77

Closed timgilbert closed 3 years ago

timgilbert commented 3 years ago

It looks like there's some code in re-graph.internals which is meant to make the query-id parameter to the ::re-graph/query event optional, but when I tried this out (in ClojureScript) I got console errors when I didn't include the parameter ("Uncaught TypeError: s.replace is not a function" coming up from the depth of re-frame). The code I was running was:

(rf/dispatch [::re-graph/query "{ randomFrame { height width pixels } }" nil [::my-callback]])

This worked fine:

(rf/dispatch [::re-graph/query :foo "{ randomFrame { height width pixels } }" nil [::my-callback]])

Possibly there's some kind of bug in the library, but anyways this PR just updates the README to reflect the usage that is working correctly.

oliyh commented 3 years ago

Hi,

Thank you for this. This is a bug so I will fix it but this will help people in the meantime! It also allows query cancellation which you can't do without an ID.

timgilbert commented 3 years ago

Awesome, thanks @oliyh! I also hit a seemingly related bug where I was getting this error about not being able to find a valid instance - even when I pass in a name I get Valid instance names are:" nil "but was provided with" nil.

It's reproducible in my codebase but I'm having trouble narrowing it down to a test case - once I do I'll file an issue.

timgilbert commented 3 years ago

(Just to follow up on that last comment, I discovered that a bug in my own code was accidentally nuking the entire :re-graph key out of the application db, so the "valid instance names" bit was due to my own errors, not anything to do with re-graph.)