How come installSubscriptionHandlers
method is not part of apollo-server-express source code and this method is mentioned here in apollo-server docs
const http = require('http');
const { ApolloServer } = require('apollo-server-express');
const express = require('express');
const app = express();
const server = new ApolloServer({ typeDefs, resolvers });
server.applyMiddleware({app})
const httpServer = http.createServer(app);
server.installSubscriptionHandlers(httpServer);
This code works and doesn't show any error despite installSubscriptionHandlers
being not a method exported from any module in the package source code.
The docs linked to are for apollo-server v2, which is maintained on the version-2
branch of the repo. The default main
branch is (at present) used to maintain v3.
In v2, the method installSubscriptionHandlers
exists on the class ApolloServerBase
exported from the package apollo-server-core.