Created
March 5, 2020 14:19
-
-
Save bogoslavskiy/a47634a4d67f49380999fb026dbd9ed4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as express from 'express'; | |
import * as mongoose from 'mongoose'; | |
import * as http from 'http'; | |
import { ApolloServer } from 'apollo-server-express'; | |
import config from './config'; | |
import schema from './schema'; | |
const app = express(); | |
const server = new ApolloServer({ | |
schema, | |
introspection: true, | |
playground: true, | |
}); | |
server.applyMiddleware({ app }); | |
const httpServer = http.createServer(app); | |
server.installSubscriptionHandlers(httpServer); | |
httpServer.listen({ port: config.port }, () => { | |
console.log(`๐ Server ready at http://localhost:${config.port}${server.graphqlPath}`) | |
console.log(`๐ Subscriptions ready at ws://localhost:${config.port}${server.subscriptionsPath}`) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment