setupGraphQLMiddlewares = async (apolloServer, config, apolloApplyMiddlewareOptions) => {
  // IMPORTANT: order matters !
  // 1 - Add request parsing middleware
  // 2 - Add apollo specific middlewares
  // 3 - CLOSE CONNEXION (otherwise the endpoint hungs)
  // 4 - ONLY THEN you can start adding other middlewares (graphql voyager etc.)

  // WebApp.connectHandlers is a connect server
  // you can add middlware as usual when using Express/Connect
  // Use the Express app instead of just Node connect (allow better middleware chaining)
  const app = express();
  // parse cookies and assign req.universalCookies object
  app.use(universalCookiesMiddleware());
  // parse request (order matters)

  app.use(
    config.path,
    // won't handle graphql
    //bodyParser.json({ limit: getSetting('apolloServer.jsonParserOptions.limit') })
    bodyParserGraphQL({ limit: getSetting('apolloServer.jsonParserOptions.limit') })
  );

  //WebApp.connectHandlers.use(config.path, bodyParser.text({ type: 'application/graphql' }));
  WebApp.connectHandlers.use(app);

  // enhance webapp
  runCallbacks({
    name: 'graphql.middlewares.setup',
    iterator: WebApp,
    properties: {},
  });

  await apolloServer.start();

  // Provide the Meteor WebApp Connect server instance to Apollo
  // Apollo will use it instead of its own HTTP server when handling requests

  //   For the list of already set middlewares (cookies, compression...), see:
  //  @see https://github.com/meteor/meteor/blob/master/packages/webapp/webapp_server.js
  apolloServer.applyMiddleware({
    ...apolloApplyMiddlewareOptions,
  });

  // setup the end point otherwise the request hangs
  // TODO: undestand why this is necessary
  // @see
  WebApp.connectHandlers.use(config.path, (req, res) => {
    if (req.method === 'GET') {
      res.end();
    }
  });
}
@see https://www.apollographql.com/docs/apollo-server/whats-new.html
@see https://www.apollographql.com/docs/apollo-server/migration-two-dot.html