Cool library, @kenwheeler ! I'm still checking out the code to see all of the features. I appreciate the simple approach you've taken here, particularly in comparison to the complexity of Apollo's source (I β€οΈ Apollo, don't get me wrong! π )
One thing I noticed is that if a user passes in 10 queries, 10 requests are made. I was thinking that it'd be neat if the queries could be stitched together.
Apollo and Relay can accomplish features like this by breaking the query down into an AST, which is powerful, but probably a little heavy-handed for what this library is doing. Luckily, the GraphQL syntax is (currently, at least) simple enough that there should be a way to do this robustly without an AST by making a few reasonable assumptions.
If you're π to this idea, I'd be happy to put together a proof of concept.
What lead me to this idea?
I noticed that urql caches at the query level, rather than the root query level. i.e.;
creates one entry in the cache, and not two.
I was going to open a similar issue to this one, suggesting that a lightweight function could be written that splits up the query for caching purposes. But then I realized that because the component accepts an array of queries, that maybe that was the recommended approach instead.
I wonder how hard it'd be to write these two functions: one that joins root queries, and the other that splits them apart.
What do you think?
Thanks for reading! βοΈ