-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
30 lines (23 loc) · 814 Bytes
/
Copy pathserver.js
File metadata and controls
30 lines (23 loc) · 814 Bytes
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
const path = require("path");
const express = require("express");
const { ApolloServer } = require("apollo-server-express");
const { loadFilesSync } = require("@graphql-tools/load-files");
const { makeExecutableSchema } = require("@graphql-tools/schema");
const typesArray = loadFilesSync(path.join(__dirname, "**/*.graphql"));
const resolversArray = loadFilesSync(path.join(__dirname, "**/*.resolvers.js"));
async function startApolloServer() {
const app = express();
const schema = makeExecutableSchema({
typeDefs: typesArray,
resolvers: resolversArray,
});
const server = new ApolloServer({
schema,
});
await server.start();
server.applyMiddleware({ app, path: "/graphql" });
app.listen(3000, () => {
console.log("Running GraphQL server...");
});
}
startApolloServer();