graphql

stefan 2019-05-09T14:47:20.076200Z

https://github.com/jaydenseric/graphql-react

stefan 2019-05-09T14:47:25.076600Z

anyone have experience using this library with cljs?

stefan 2019-05-09T14:47:45.077200Z

thinking about using it so I can get away from the function as a child pattern in my Apollo components

stefan 2019-05-09T14:48:26.078100Z

it also seems to have some other solid benefits like smaller bundle size, auto refreshing cache on component mount

stefan 2019-05-09T14:54:24.079200Z

@lilactown I saw you mentioned using apollo-client directly instead of react-apollo. how has that been?

gklijs 2019-05-09T15:05:07.080300Z

For cljs, especially if you use re-frame, but also if not, https://github.com/oliyh/re-graph works very nice.

stefan 2019-05-09T15:09:48.082300Z

I did try out re-graph, one thing I struggled with was how I should use the result of a query to render a component, since it fires a callback instead of returning a value.

stefan 2019-05-09T15:11:27.084Z

I’m coming from js where I would do something like const CarList = () => <Query>{ ({data}) => <list>{data.cars}</list> }</Query>

stefan 2019-05-09T15:12:59.085500Z

I’m using hooks for state instead of re-frames app-db

stefan 2019-05-09T15:16:04.087400Z

and writing out the fn as a child pattern in cljs is a pain. It would be nice to be able to do

stefan 2019-05-09T15:16:10.087600Z

(defnc my-component [] (let [{:keys [data error loading]} (use-query my-query)][:list …]))

lilactown 2019-05-09T15:16:43.087700Z

@stefan.age if you're using hx, I would try react-apollo first

lilactown 2019-05-09T15:17:45.088700Z

I think there's a hook version maybe?

stefan 2019-05-09T15:18:01.089Z

Yeah there’s react-apollo-hooks

stefan 2019-05-09T15:18:14.089400Z

Just thought graphql-react looked interesting as well

stefan 2019-05-09T15:18:40.090Z

But then realized maybe I can get away from fn as a child components with apollo-client

lilactown 2019-05-09T15:19:20.090700Z

you could, but you would have to build the hooks yourself

stefan 2019-05-09T15:19:46.090900Z

ah ok

lilactown 2019-05-09T15:20:04.091Z

for reagent, we built a wrapper that takes the apollo-client observable and wraps it in a reagent atom

lilactown 2019-05-09T15:20:42.091100Z

it works well now but it was some work and ongoing maintenance

lilactown 2019-05-09T15:21:30.091200Z

graphql-react does look pretty nice w.r.t. bundle size

lilactown 2019-05-09T15:22:31.091300Z

the other thing I appreciate about apollo is the devtools. but YMMV

stefan 2019-05-09T15:26:10.092300Z

yeah I think I’m leaning toward react-apollo-hooks with react-apollo since I’m pretty familiar with apollo already