I have a queries file that looks like this:
import {gql} from \'react-apollo\';
const queries = {
getApps: gql`
{
apps {
id
name
If you don't want to reuse any of those queries independently, why not make a single request by combining both queries in one i.e:
const combinedQueries = gql`
{
apps {
id
name
}
subjects {
id
name
}
}
`
and then you can use it in your component
import React, {Component} from 'react'
import combinedQueries from './combinedQueries'
class Test extends Component {
...
render() {
...
if(!this.props.combinedQueries.loading) {
console.log(this.props.combinedQueries.apps);
console.log(this.props.combinedQueries.subjects);
}
...
}
}
export default graphql(combinedQueries, {name: 'combinedQueries'})(Test);