title: Apollo Configuration Error?
body: <p>I've got a lot of Apollo code that has worked perfectly for 6+ months with old versions of the Apollo libraries. I'm seeking to update it to work with the latest versions of the Apollo libraries. </p>
  
  <p>Currently my queries run fine when run in graphIQL, but when run from my own front-end code, I get the error:</p>
  
  <blockquote>
    <p>Unhandled (in react-apollo) Error: Network error: Network request failed with status 200 - "OK"</p>
  </blockquote>
  
  <p>Here's a screen shot showing the stack trace:</p>
  
  <p><a href="https://i.stack.imgur.com/B4xg8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B4xg8.png" alt="enter image description here"></a></p>
  
  <p>Could it a configuration error in the initial setup for connecting with Apollo?</p>
  
  <p><strong>SERVER SETUP</strong></p>
  
  <pre><code>import { subscriptionManager, pubsub } from '/imports/api/subscriptions-server';
  import schema from '/imports/api/schema';
  import  cors  from 'cors';
  
  //SET UP APOLLO QUERY AND MUTATIONS
  import express from 'express';
  import bodyParser from 'body-parser';
  import { graphqlExpress, graphiqlExpress } from 'graphql-server-express';
  const GRAPHQL_PORT = 3010;
  var graphQLServer = express().use('*', cors());
  graphQLServer.use('/graphql', bodyParser.json(), graphqlExpress(request =&gt; ({
      schema: schema
  })));
  graphQLServer.use('/graphiql', graphiqlExpress({
      endpointURL: '/graphql',
  }));
  graphQLServer.listen(GRAPHQL_PORT);
  
  
  console.log(
      `GraphQL Server is now running on http://localhost:${GRAPHQL_PORT}/graphql`
  );
  console.log(
      `GraphIQL available on http://localhost:${GRAPHQL_PORT}/graphiql`
  );
  //END OF SET UP APOLLO QUERIES AND MUTATIONS
  
  //SET UP APOLLO PUBSUB
  // WebSocket server for subscriptions
  import { createServer } from 'http';
  import { execute, subscribe } from 'graphql';
  import { SubscriptionServer } from 'subscriptions-transport-ws';
  const SUBSCRIPTION_PORT = 5000;
  // Create WebSocket listener server
  const websocketServer = createServer((request, response) =&gt; {
      response.writeHead(404);
      response.end();
  });
  // Bind it to port and start listening
  websocketServer.listen(SUBSCRIPTION_PORT, () =&gt; console.log(
      `Websocket Server is now running on http://localhost:${SUBSCRIPTION_PORT}`
  ));
  const subscriptionsServer = new SubscriptionServer(
      {
          execute,
          subscribe,
          schema,
      },
      {
          server: websocketServer
      }
  );
  //END OF SET UP APOLLO PUBSUB
  </code></pre>
  
  <p>...and here is my setup code on the client:</p>
  
  <p><strong>CLIENT SETUP</strong></p>
  
  <pre><code>import {GET_USERINFOFORIMS_QUERY} from '/imports/api/query-library';
  import { gql, ApolloClient, createNetworkInterface, ApolloProvider, graphql, createBatchingNetworkInterface, addTypename } from 'react-apollo';
  import { SubscriptionClient, addGraphQLSubscriptions } from 'subscriptions-transport-ws';
  
  const subscriptionClient = new SubscriptionClient(`ws://localhost:5000/`, {
      reconnect: true
  });
  
  // Create a normal network interface:
  const networkInterface = createNetworkInterface({
      uri: 'http://localhost:3000',
      opts: {
          credentials: 'same-origin',
      },
      transportBatching: true,
      batchInterval: 10
  
  });
  // Extend the network interface with the WebSocket
  const networkInterfaceWithSubscriptions = addGraphQLSubscriptions(
      networkInterface,
      subscriptionClient
  );
  
  const ApolloClientWithSubscribeEnabled = new ApolloClient({
      networkInterface: networkInterfaceWithSubscriptions,
      queryTransformer: addTypename,
      dataIdFromObject: (result) =&gt; {
          if (result.id &amp;&amp; result.__typename) { // eslint-disable-line no-underscore-dangle
              return result.__typename + result.id; // eslint-disable-line no-underscore-dangle
          }
          return null;
      },
      shouldBatch: true,
      initialState: window.__APOLLO_STATE__, // eslint-disable-line no-underscore-dangle
      ssrForceFetchDelay: 100
  });
  </code></pre>
  
  <p><strong>CLIENT-SIDE QUERY</strong></p>
  
  <pre><code>getUserInfoForCurrentUser() {
      const userIsLoggedIn = Meteor.userId() ? true : false;
      if ((userIsLoggedIn) &amp;&amp; (this.originatingUser == null)){
          const localThis = this;
          const userID = Meteor.userId();
          this.client.query({
              query: GET_USERINFOFORIMS_QUERY,
              variables: {userID: userID},
          }).then((result) =&gt; {
              localThis.originatingUser = result.data.getUserData[0];
          });
      }
  }
  </code></pre>
  
  <p>As noted, the queries run fine from graphIQL.</p>
  
  <p>Am I making an error in my code that connects to Apollo?</p>
  
  <p>Thanks very much in advance to all for any thoughts or info.</p>