Skip to content

Instantly share code, notes, and snippets.

@LazyFatArrow LazyFatArrow/index.js
Last active Mar 9, 2019

Embed
What would you like to do?
// 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
You can’t perform that action at this time.