Guest User

Untitled

a guest
Apr 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import express from 'express';
  2. import {graphiqlExpress, graphqlExpress } from 'apollo-server-express';
  3. import bodyParser from 'body-parser';
  4. import mongoose from 'mongoose';
  5. import schema from './schema';
  6.  
  7. const server = express();
  8.  
  9. server.use('/graphiql', graphiqlExpress({
  10. endpointURL: "/graphql"
  11. }))
  12.  
  13. mongoose.connect('mongodb://localhost/graphqlTutorial')
  14.  
  15. const connection = mongoose.connection;
  16.  
  17. connection.once('open', () => {
  18. console.log('====================================')
  19. console.log('Connection to DB open!')
  20. console.log('====================================')
  21. })
  22.  
  23. server.use('/graphql',bodyParser.json(), graphqlExpress({
  24. schema
  25. }))
  26.  
  27.  
  28. server.listen(4000, () => {
  29. console.log('Server ready on port 4000')
  30. })
Add Comment
Please, Sign In to add comment