我正在尝试将我的本机应用程序作为graphql客户端,我曾经使用过redux并添加了graphql。我遇到了错误,图片表明了这一点。
import { createStore, applyMiddleware, combineReducers } from 'redux';
import { persistReducer } from 'redux-persist';
import AsyncStorage from '@react-native-community/async-storage';
import thunk from 'redux-thunk';
import { ApolloClient } from 'apollo-client';
import { apolloReducer } from 'apollo-cache-redux';
import { InMemoryCache } from 'apollo-cache-inmemory';
import ReduxLink from 'apollo-link-redux';
import { onError } from 'apollo-link-error';
import { createHttpLink } from 'apollo-link-http';
import { accountReducer } from './account.reducer';
import { ApolloLink } from 'apollo-link';
const persistConfiguration = { key: 'spottd', storage: AsyncStorage };
const rootReducer = combineReducers({ accountReducer, apolloReducer });
const persistedReducer = persistReducer(persistConfiguration, rootReducer);
const store = createStore(persistedReducer, {}, applyMiddleware(thunk));
const cache = new new InMemoryCache();
const reduxLink = new ReduxLink(store);
const httpLink = createHttpLink({ uri: `https://dcef73ba.ngrok.io/graphql` });
const errorLink = onError((errors) => { console.log(errors); });
const link = ApolloLink.from([ reduxLink, errorLink, httpLink, ]);
const client = new ApolloClient({ link, cache });
export default store;
export { link, client }