title: GraphQLServer + Socket-io on same port
body: <p>I have a working project with GraphQLServer serving my react app from port 4000 and socket-io listening on port 5000.</p>
  
  <p><strong>I'm trying to deploy to heroku so I need them to be on the same port</strong> (process.env.PORT), but I can't figure out how to do it with GraphQLServer.</p>
  
  <p><a href="https://stackoverflow.com/questions/12235406/how-to-use-expressjs-and-socket-io-on-a-same-port">This is how to do it with express + socket-io</a></p>
  
  <p><a href="https://github.com/prisma/graphql-yoga#startoptions-options-callback-options-options--void----null-promisevoid" rel="nofollow noreferrer">This is the start script for GraphQLServer</a></p>
  
  <p><a href="https://gist.github.com/baconcheese113/edbc738379a53792dd3cce0f4c8ad5ba#file-server-index-js" rel="nofollow noreferrer">Gist with my current code is here</a></p>
  
  <p>Relevant code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import server from './server';
  import express from 'express';
  import path from 'path';
  
  const http = require('http').Server(server.express);
  const io = require('socket.io')(http);
  require('./socket')(io);
  
  server.express.use(express.static(path.join(__dirname, '../../client/build')));
  server.express.get('/*', function(req, res) {
    res.sendFile(path.join(__dirname, '../../client/build', 'index.html'));
  });
  
  // Socket-io listener
  http.listen({
      port: process.env.PORT || 5000
    }, () =&gt;
    console.log('listening on port ' + process.env.PORT || 5000)
  );
  
  // GraphQL and app listener
  server.start({
      cors: {
        credentials: true,
        origin: '/'
      }
      // port: process.env.PORT || 4000
    },
    () =&gt; {
      console.log('The server is up!');
    }
  );</code></pre>
  </div>
  </div>
  </p>