On IOS, the application runs correctly. But on Android I get this error. Here's my config in client and server. Please help!
Error: Error image
Here's the config on client:
import ApolloClient, { createNetworkInterface } from 'apollo-client';
import { SubscriptionClient, addGraphQLSubscriptions } from 'subscriptions-transport-ws';
const networkInterface = createNetworkInterface({ uri: 'http://localhost:3000/graphql' });
const wsClient = new SubscriptionClient('ws://localhost:3000/subscriptions', {
reconnect: true,
});
const networkInterfaceWithSubscriptions = addGraphQLSubscriptions(
networkInterface,
wsClient,
);
export const client = new ApolloClient({
networkInterface: networkInterfaceWithSubscriptions,
});
Here's the config on server:
import express from 'express';
import {
graphqlExpress,
graphiqlExpress,
} from 'graphql-server-express';
import bodyParser from 'body-parser';
import cors from 'cors';
import { execute, subscribe } from 'graphql';
import { createServer } from 'http';
import { SubscriptionServer } from 'subscriptions-transport-ws';
import { schema } from './schema';
const PORT = 3000;
const server = express();
server.use('*', cors({ origin: 'http://localhost:8081' }));
server.use('/graphql', bodyParser.json(), graphqlExpress({ schema }));
server.use('/graphiql', graphiqlExpress({
endpointURL: '/graphql',
subscriptionsEndpoint: 'ws://localhost:3000/subscriptions',
}));
// We wrap the express server so that we can attach the WebSocket for subscriptions
const ws = createServer(server);
ws.listen(PORT, () => {
console.log('GraphQL Server is running');
// Set up the WebSocket for handling GraphQL subscriptions
new SubscriptionServer({
execute,
subscribe,
schema
}, {
server: ws,
path: '/subscriptions',
});
});
I'm using react-apollo: 1.4.10, apollo-client: 1.9.0-0