/** * Configure dotenv: * https://www.npmjs.com/package/dotenv * * Configure CORS for use with localhost. */ require('dotenv').config() const { GraphQLServer } = require('graphql-yoga') const cookieParser = require('cookie-parser') const bodyParser = require('body-parser') const cors = require('cors') const express = require('express') const { merge } = require('lodash') const { db, populateUser } = require('./src/db') // const { authenticate } = require('./src/authenticate') const prismaResolvers = require('./src/resolvers') // const typeDefs = ['./schema.graphql', system.typeDefs, interfaces.typeDefs] const resolvers = merge( // system.resolvers, // interfaces.resolvers, prismaResolvers.resolvers ) const typeDefs = ['./schema.graphql'] const server = new GraphQLServer({ typeDefs, resolvers, context: req => ({ ...req, db, debug: true }) }) server.express.use(cookieParser()) server.express.use(bodyParser.json()) // server.express.use(quickMiddleware) // server.express.use(authenticate) server.express.use(populateUser) server.express.use( cors({ origin: process.env.FRONTEND_URL, credentials: true }) ) server.express.use('/static', express.static('static')) server.start( { cors: { credentials: true, origin: process.env.FRONTEND_URL } }, server => console.log(`Server is running on http://localhost:${server.port}`) )