Last active
March 9, 2019 19:02
-
-
Save LazyFatArrow/7f1b1e5def740e673de11dd8a7f5f60a 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
// load .env content into process.env | |
require('dotenv').config() | |
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