I have a queries file that looks like this:
import {gql} from \'react-apollo\';
const queries = {
getApps: gql`
{
apps {
id
name
IMHO, one of the most neat solutions is described in the Apollo Client React implementation.
The basic idea is to wrap your queries into nested Query components. Using closure functions as component children makes it handy to delegate the results of one query down into another query and so on.
const QueryOne = gql`
query One {
one
}
`;
const QueryTwo = gql`
query Two {
two
}
`;
const NumbersWithData = () => (
{({ loading: loadingOne, data: { one } }) => (
{({ loading: loadingTwo, data: { two }}) => {
if (loadingOne || loadingTwo) return loading...
return {one} is less than {two}
}}
)}
);