-
Notifications
You must be signed in to change notification settings - Fork 0
/
gateway.js
33 lines (30 loc) · 860 Bytes
/
gateway.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
32
33
const { ApolloServer } = require("apollo-server");
const { ApolloGateway } = require("@apollo/gateway");
require('dotenv').config();
const gateway = new ApolloGateway({
serviceList: [
{ name: "customers", url: "http://localhost:4001" },
{ name: "orders", url: "http://localhost:4002" },
{ name: "products", url: "http://localhost:4003" },
{ name: "reviews", url: "http://localhost:4004/graphql" }
]
});
const server = new ApolloServer({
gateway,
subscriptions: false,
engine: {
apiKey: process.env.ENGINE_API_KEY,
},
persistedQueries: {}, // default in-memory cache
formatError: error => {
console.log(error);
return error;
},
formatResponse: response => {
console.log(response);
return response;
},
});
server.listen().then(({ url }) => {
console.log(`🚀 Gateway Server ready at ${url}`);
});