cult-of-coders / grapher-react

Provides easy to use React Components that are suitable for grapher package.
https://atmospherejs.com/cultofcoders/grapher-react
39 stars 19 forks source link

Fetching multiple queries #3

Closed jthomaschewski closed 6 years ago

jthomaschewski commented 7 years ago

I often need data from multiple, unrelated collections in a react component. I'm not quite sure how to fetch them properly.

Currently I'd have to do something like this: createQueryContainer(query1, createQueryContainer(query2, Component, options2), options1)

Possible solutions:

I'm quite new to grapher and GraphQL-style queries in general. So maybe I'm trying to work against the concept and these queries shouldn't be required?

theodorDiaconu commented 7 years ago

@jbbr if you need data, from 2 unrelated collections in 1 react component, good one! I would extend createQueryContainer, to allow as first argument a query or an object of queries {{x: query1, y: query2}}.

But my question is why don't you use componentDidMount, and do the fetching manually ? This looks very confusing: createQueryContainer(query1, createQueryContainer(query2, Component, options2), options1)

Allowing multiple root points... I need to think about it. ( I added it as a issue in grapher ) The problem arises when you want to make it reactive, you would still have to subscribe to two different publications. One publication can be ready, the other may not be ready, when do we return the data, wouldn't keeping them in isolation be best.