mirror of
https://github.com/seigler/graphql-playground
synced 2025-07-27 01:26:10 +00:00
feat(server): connect to MongoDB
This commit is contained in:
parent
c44f536788
commit
62b1a67be7
5 changed files with 166 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue