【发布时间】:2017-12-04 17:09:14
【问题描述】:
当我尝试做两个不同的查询时,我得到了这个错误我该如何解决它
``错误:需要查询选项。您必须在查询选项中指定您的 GraphQL 文档。
这是代码的 sn-p
//in my index class I dispatch some actions
componentDidMount () {
this.props.fetchNavigationBarDataThunk();
this.props.fetchActionToDoTitleDataThunk();
}
//then in my action I have something like that
import ApolloClient, { createNetworkInterface } from 'apollo-client';
import gql from 'graphql-tag';
const opts = {uri: 'http://localhost:8080/wfgen/graphql'};
const networkInterface = createNetworkInterface(opts);
const client = new ApolloClient({networkInterface});
var query1 = gql`query {...}`;
var query2= gql`query {...}`;
export function fetchActionToDoTitleDataThunk () {
return (dispatch) => {
dispatch(fetchActionToDoTitleData())
client.query({ query2 }).then((results) => {
if (results.networkStatus === 7 && results.loading === false) {
dispatch(fetchActionToDoTitleDataFulFilled(results));
}
else{
...
export function fetchNavigationBarDataThunk () {
return (dispatch) => {
dispatch(fetchNavigationBarData())
client.query({query}).then((results) => {
if (results.networkStatus === 7 && results.loading === false) {
dispatch(fetchNavigationBarDataFulFilled(results));
}
else{
....
【问题讨论】:
标签: reactjs redux react-redux graphql apollo