Skip to content

Instantly share code, notes, and snippets.

@dimuthu
Created February 10, 2020 09:39
Show Gist options
  • Save dimuthu/9ba37d61c22c9068b9126337d1786338 to your computer and use it in GitHub Desktop.
Save dimuthu/9ba37d61c22c9068b9126337d1786338 to your computer and use it in GitHub Desktop.
const express = require('express');
const graphqlHTTP = require('express-graphql');
const mongo = require('mongoose');
const app = express();
const schema = require('./schema/schema');
mongo.connect('mongodb://mongo:27017/example', {
useNewUrlParser: true,
useUnifiedTopology: true
})
mongo.connection.once('open', () => {
console.log('connected to database');
})
app.use('/graphql', graphqlHTTP({
graphiql: true,
schema: schema
}));
app.listen(8080, () => {
console.log('Server running succefully...')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment