Skip to content

Instantly share code, notes, and snippets.

@tkssharma
Created September 10, 2019 09:45
Show Gist options
  • Save tkssharma/947e6602a29a7ed7ff77d74d7f87c14a to your computer and use it in GitHub Desktop.
Save tkssharma/947e6602a29a7ed7ff77d74d7f87c14a to your computer and use it in GitHub Desktop.
const server = new ApolloServer({
typeDefs,
resolvers,
context: ({ req }) => ({
dbContext: new Database(global.connection),
me: getLoggedInUser(req),
}),
});
server.applyMiddleware({ app });
if (!module.parent) {
eventEmitter.on('dbReady', connection => {
// global.connection = connection;
app.listen({ port: process.env.PORT || 3000 }, () =>
// eslint-disable-next-line no-console
console.log(`πŸš€ πŸš€ πŸš€ πŸš€ Server ready at http://localhost:3000${server.graphqlPath} πŸš€ πŸš€ πŸš€ `),
);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment