有什么方法可以更改 Apollo Server WS 的路径(server.subscriptionsPath)?
默认路径是“/graphql”。如何设置其他路由,例如“ws://localhost:3000/api”?
import express from 'express'
import http from 'http'
import { ApolloServer } from 'apollo-server-express'
const app = express()
// ...
const server = new ApolloServer({
typeDefs,
resolvers,
})
const httpServer = http.createServer(app)
server.installSubscriptionHandlers(httpServer)
console.log('server.graphqlPath', server.graphqlPath)
console.log('server.subscriptionsPath', server.subscriptionsPath)
httpServer.listen({ port:300 })
Run Code Online (Sandbox Code Playgroud)