MCPcopy Create free account
hub / github.com/prisma/prisma-examples / start

Function start

orm/graphql-subscriptions/src/server.ts:21–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19const httpServer = createServer(app)
20
21async function start() {
22 /** Create WS Server */
23 const wsServer = new WebSocketServer({
24 server: httpServer,
25 path: '/graphql',
26 })
27
28 /** hand-in created schema and have the WS Server start listening */
29 const serverCleanup = useServer({ schema, context }, wsServer)
30
31 const server = new ApolloServer<Context>({
32 schema,
33 plugins: [
34 ApolloServerPluginDrainHttpServer({ httpServer }),
35 {
36 async serverWillStart() {
37 return {
38 async drainServer() {
39 await serverCleanup.dispose()
40 },
41 }
42 },
43 },
44 ],
45 })
46
47 await server.start()
48 app.use('/graphql', cors<cors.CorsRequest>(), express.json(), expressMiddleware(server, { context: async () => context }));
49
50 httpServer.listen(PORT, () => {
51 console.log(`🚀 Server ready at http://localhost:${PORT}/graphql`)
52 console.log(`⏰ Subscriptions ready at http://localhost:${PORT}/graphql`)
53 console.log(
54 `⭐️ See sample queries: http://pris.ly/e/ts/graphql-subscriptions#using-the-graphql-api`,
55 )
56 })
57}
58
59start()

Callers 1

server.tsFile · 0.70

Calls 4

listenMethod · 0.80
startMethod · 0.65
jsonMethod · 0.65
logMethod · 0.65

Tested by

no test coverage detected