-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
30 lines (23 loc) · 943 Bytes
/
index.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
const express = require("express");
const { ApolloServer } = require("apollo-server-express");
const { ApolloGateway } = require("@apollo/gateway");
const { express: voyagerMiddleware } = require("graphql-voyager/middleware");
const gateway = new ApolloGateway({
serviceList: [
{ name: "movie-studio", url: "http://movie-studio/gql" },
{ name: "movie-theatre", url: "http://movie-theatre/gql" },
{ name: "movie-reviews", url: "http://movie-reviews/gql" },
],
});
const app = express();
// Pass the ApolloGateway to the ApolloServer constructor
const server = new ApolloServer({
gateway,
// Disable subscriptions (not currently supported with ApolloGateway)
subscriptions: false,
});
app.use("/voyager", voyagerMiddleware({ endpointUrl: server.graphqlPath }));
server.applyMiddleware({ app });
app.listen(process.env.port || 4000, () => {
console.log(`🚀 Server ready on port ${process.env.port || 4000}`);
});