Last active
March 9, 2019 19:02
-
-
Save LazyFatArrow/12ec3940d9461c6f32f8023f3d94e8d0 to your computer and use it in GitHub Desktop.
This file contains 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 "@babel/polyfill"; | |
import mongoose from 'mongoose' | |
import { resolve } from 'path' | |
import { mergeTypes, fileLoader } from 'merge-graphql-schemas'; | |
import { ApolloServer, gql } from 'apollo-server' | |
import resolvers from './resolvers' | |
const schema = mergeTypes( | |
fileLoader(resolve(__dirname, './schema')) | |
) | |
const apolloOptions = { | |
typeDefs: gql(schema), | |
resolvers, | |
} | |
mongoose.connect(process.env.MONGO_URI, { useNewUrlParser: true }) | |
.then(() => { | |
return new ApolloServer(apolloOptions).listen( | |
parseInt(process.env.SERVER_PORT) | |
) | |
}) | |
.then(({ url, subscriptionsUrl }) => { | |
console.log(`🚀 Server ready at ${url}`); | |
console.log(`🚀 Subscriptions ready at ${subscriptionsUrl}`); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment