I got this error in my application (react-native) when internet connection is lost. When i start the app on offline mode, Initial component renders, try to execute the query, app crashes. it works perfect when my app is connected with internet. But my application crashes when its not. How can i handle this error?未処理エラーネットワークエラー:ネットワーク要求がエラーを失敗しました:ネットワーク要求がエラーを失敗しました:71「未処理エラーネットワークエラー:ネットワーク要求がエラーを失敗しました:ネットワークエラー:ネットワーク要求が新しいで失敗した新しいApolloError
ExceptionsManager.jsでApolloError」
import ApolloClient, { createNetworkInterface } from 'apollo-client';
import { AsyncStorage } from 'react-native';
import {SubscriptionClient, addGraphQLSubscriptions} from 'subscriptions-transport-ws';
const wsClient = new SubscriptionClient('wss://172.20.32.6:5000', {
reconnect: true,
connectionParams: {
accessToken: 'jka sdhkjashd jkashdjk ashdas'
}
});
const networkInterface = createNetworkInterface({
uri: 'http://172.20.32.6:8000/graphql',
opts: {
credentials: 'same-origin'
}
});
const networkInterfaceWithSubscriptions = addGraphQLSubscriptions(
networkInterface,
wsClient
);
const client = new ApolloClient({
dataIdFromObject: o => o.id,
networkInterface: networkInterfaceWithSubscriptions
});
networkInterface.use([{
applyMiddleware(req, next) {
if (!req.options.headers) {
req.options.headers = {}; // Create the header object if needed.
}
// get the authentication token from local storage if it exists
AsyncStorage.getItem('sessionToken').then((token) => {
req.options.headers.Authorization = token ? `${token}` : null;
next();
}
);
}
}]);
export default client;