forked from apollographql/federation-demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgateway.js
37 lines (31 loc) · 1.38 KB
/
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
34
35
36
37
const { ApolloServer } = require("apollo-server");
const { ApolloGateway } = require("@apollo/gateway");
const gateway = new ApolloGateway({
// This entire `serviceList` is optional when running in managed federation
// mode, using Apollo Graph Manager as the source of truth. In production,
// using a single source of truth to compose a schema is recommended and
// prevents composition failures at runtime using schema validation using
// real usage-based metrics.
serviceList: [
{ name: "accounts", url: "http://localhost:4001/graphql" },
{ name: "reviews", url: "http://localhost:4002/graphql" },
{ name: "products", url: "http://localhost:4003/graphql" },
{ name: "inventory", url: "http://localhost:4004/graphql" }
],
// Experimental: Enabling this enables the query plan view in Playground.
__exposeQueryPlanExperimental: false,
});
(async () => {
const server = new ApolloServer({
gateway,
// Apollo Graph Manager (previously known as Apollo Engine)
// When enabled and an `ENGINE_API_KEY` is set in the environment,
// provides metrics, schema management and trace reporting.
engine: false,
// Subscriptions are unsupported but planned for a future Gateway version.
subscriptions: false,
});
server.listen().then(({ url }) => {
console.log(`🚀 Server ready at ${url}`);
});
})();