Skip to content

Instantly share code, notes, and snippets.

@bogoslavskiy
Created March 5, 2020 14:19
Show Gist options
  • Save bogoslavskiy/a47634a4d67f49380999fb026dbd9ed4 to your computer and use it in GitHub Desktop.
Save bogoslavskiy/a47634a4d67f49380999fb026dbd9ed4 to your computer and use it in GitHub Desktop.
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