-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
27 lines (24 loc) · 780 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const express = require('express');
const bodyParser = require('body-parser');
const mongoose = require('mongoose');
const typeDefs = require('./graphql/schema/index');
const resolvers = require('./graphQL/resolver/index');
const { GraphQLServer } = require('graphql-yoga');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
var database = "mongodb://localhost:27017/test"
mongoose.connect(database)
.then(() => {
console.log('Connection to DB successful');
})
.catch(err => {
console.log('Db connection error====', err);
});
const server = new GraphQLServer({
typeDefs,
resolvers
});
server.start({port: 5050}).then(result => {
console.log('GraphQL Listening on port 5050');
});