-
Notifications
You must be signed in to change notification settings - Fork 8
/
server.js
42 lines (31 loc) · 968 Bytes
/
server.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
require('dotenv').config();
// Imports apollo and graphql stuff we need
const { ApolloServer } = require('apollo-server-express');
// middleware imports
const express = require('express');
// const morgan = require('morgan');
// const cors = require('cors');
// const helmet = require('helmet');
const app = express();
// ***************** GRAPHQL *********************
const resolvers = require('./resolvers');
const typeDefs = require('./schema');
// ***************** MIDDLEWARE ******************
// app.use(morgan('dev'));
app.use(express.json());
// app.use(cors());
// app.use(helmet());
// ***************** TEST ENDPOINT ***************
app.get('/', async (req, res) => {
res.send('<h1>She works</h1>');
});
// Creates a new instance of apollo and
// feeds it out gql data
const server = new ApolloServer({
typeDefs,
resolvers,
});
// wraps our GQL server with our entire
// express app
server.applyMiddleware({ app });
module.exports = app;