Fork me on GitHub
#graphql
<
2019-05-09
>
stefan14:05:25

anyone have experience using this library with cljs?

stefan14:05:45

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

stefan14:05:26

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

stefan14:05:24

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

gklijs15:05:07

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

stefan15:05:48

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.

stefan15:05:27

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

stefan15:05:59

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

stefan15:05:04

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

stefan15:05:10

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

lilactown15:05:43

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

lilactown15:05:45

I think there's a hook version maybe?

stefan15:05:01

Yeah there’s react-apollo-hooks

stefan15:05:14

Just thought graphql-react looked interesting as well

stefan15:05:40

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

lilactown15:05:20

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

lilactown15:05:04

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

lilactown15:05:42

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

lilactown15:05:30

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

lilactown15:05:31

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

stefan15:05:10

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