It is not ok to start the apollo server in advance. What happens with the case when I have to explicitly use http/https. Please see the following case:
  const server = new ApolloServer({
    typeDefs: [KeycloakTypeDefs, typeDefs], // 1. Add the Keycloak Type Defs
    schemaDirectives: KeycloakSchemaDirectives, // 2. Add the
    formatError: new ApolloErrorConverter(),
    resolvers: resolvers,
    context: ({ req }) => {
      return makeContextWithDependencies(req);
    }
  });
  server.applyMiddleware({ app });
  http.createServer(app).listen(config.server.port, os.hostname());
  const options = {
    key: fs.readFileSync(config.server.ssl.keyFile, "utf8"),
    cert: fs.readFileSync(config.server.ssl.certFile, "utf8"),
    passphrase: config.server.ssl.passphrase
  };
  https
    .createServer(options, app)
    .listen(config.server.securePort, os.hostname());
  console.log(
    "Server waiting for requests on ports: " +
      config.server.port +
      "," +
      config.server.securePort
  );