-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
31 lines (24 loc) · 850 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
const express = require("express");
const { ApolloServer} = require("apollo-server-express");
const cors = require("cors")
const path = require("path")
// Construct a schema, using GraphQL schema language
const typeDefs = require('./graphql/schema')
// Provide resolver functions for your schema fields
const resolvers = require("./graphql/resolvers")
const server = new ApolloServer({
typeDefs,
resolvers,
playground: { endpoint: "/graphql", settings: { "editor.theme": "dark" } }
});
const app = express();
app.use(cors())
server.applyMiddleware({ app });
app.use(express.static('public'))
app.get('*',(req,res)=>{
res.sendFile(path.resolve(__dirname,'public','index.html'))
})
const PORT = process.env.PORT || 5000
app.listen(PORT, () =>
console.log(`🚀 Server ready at http://localhost:5000${server.graphqlPath}`)
);