Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

[2.1 beta]: Query enhancement request #1662

Closed
serle opened this issue Feb 10, 2018 · 5 comments
Closed

[2.1 beta]: Query enhancement request #1662

serle opened this issue Feb 10, 2018 · 5 comments

Comments

@serle
Copy link

serle commented Feb 10, 2018

I would like to be able to pass multiple named queries to the query component as opposed to just one and get back multiple result objects for use in my render function. I would like the array of queries to be batched and for the query component to render only once all the queries have returned.

@kandros
Copy link
Contributor

kandros commented Feb 15, 2018

Isn’t a composition of HOCs more appropriate for this usecase?

@rosskevin
Copy link
Contributor

The goal is for Query to be singular in purpose. As @kandros said, there are multiple ways to compose queries.

For the purposes of batching, you might consider batching with apollo-link: https://github.com/apollographql/apollo-link/tree/master/packages/apollo-link-batch-http

@serle
Copy link
Author

serle commented Feb 19, 2018

I find the Query component is far clearer than using the HOC approach. I don't have a strong opinion on the singular nature of the Query component, only that my use-case requires multiple queries to return successfully before I start to render. This requires some sort of execute queries in parallel component.

It would be even better to think in terms of query chaining of both parallel query pipelines and serial query pipelines where a serial query pipeline occurs when the result data from one query is used as a parameter to the next query in the chain. Composing parallel and serial query chains with a secondary loading and error render props would clarify a lot of my code. i.e. let the child render prop render the success case and relegate the common loading and error rendering to two alternate props.

@kandros
Copy link
Contributor

kandros commented Feb 19, 2018

Don’t get me wrong but this looks like what graphql is trying to avoid in the first place.

@serle
Copy link
Author

serle commented Feb 19, 2018

Yes one could say make a special complex API for the parallel query case, but in some of my cases the data being called is independent fact data.

An example is when we have a UI to capture a three way relationship between independent fact entities. Here one could have three select fields rendered by the component each consuming one of the query result. It makes sense to only start rendering when all 3 queries return and all the option data is available to capture the relationship.

The other design would be to create one composite API call for all the options but then the schema gets bloated very quickly with very specific UI cases. I'd rather take advantage of Apollo normalization and the ability to batch multiple Queries.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants