title: How do I make GraphQL subscriptions in NodeJS via Apollo Client?
body: <p>I want to make a subscription to a GraphQL server. The application is running in a NodeJS script (i.e. not in the webbrowser).</p>
  
  <p>Here is what I currently do:</p>
  
  <pre><code>const fetch = require("node-fetch").default;
  const apollo = require("apollo-boost");
  const ApolloClient = apollo.default;
  const { gql } = require("apollo-server");
  
  const apolloClient = new ApolloClient({
    uri: "http://localhost:4000/graphql",
    fetch
  });
  
  apolloClient.subscribe({
    query: gql`
      subscription {
        startTaskRequested {
          pkRobot
          taskName
        }
      }
    `,
  }).subscribe({
    next(x) { console.log(x) },
    error(err) { console.log(`Finished with error: ${ err }`) },
    complete() { console.log('Finished') }
  });
  </code></pre>
  
  <p>The resulting ouput is:</p>
  
  <pre><code>{ data: { startTaskRequested: null } }
  Finished
  </code></pre>
  
  <p>On the GraphQL Server, I can see that the corresponding resolver is never called.</p>
  
  <p>If I make the same subscription query using Apollo's Playground, the subscription works and I get the results that I expect: <a href="https://i.stack.imgur.com/WcfJQ.png" rel="noreferrer">Apollo Playground</a></p>
  
  <p>I bumped my head against this for many hours already and I would greatly appreciate it if someone could point me in the right direction.</p>