feat(server): connect to MongoDB

This commit is contained in:
Joshua Seigler 2020-01-29 00:24:42 -05:00
parent c44f536788
commit 62b1a67be7
5 changed files with 166 additions and 4 deletions

View file

@ -1,10 +1,20 @@
const express = require('express');
const graphqlHTTP = require('express-graphql');
const mongoose = require('mongoose');
require('dotenv-safe').config();
const schema = require('./schema/schema');
const app = express();
mongoose.connect(process.env.connectionString, {
useUnifiedTopology: true,
useNewUrlParser: true
});
mongoose.connection.once('open', () => {
console.log('Connected to database.');
});
app.use('/graphql', graphqlHTTP({
schema,
graphiql: true