forked from Gusto/apollo-federation-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgateway.js
25 lines (21 loc) · 804 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
const { ApolloServer } = require('@apollo/server');
const { ApolloGateway, IntrospectAndCompose } = require('@apollo/gateway');
const { startStandaloneServer } = require('@apollo/server/standalone');
const gateway = new ApolloGateway({
supergraphSdl: new IntrospectAndCompose({
subgraphs: [
{ name: 'accounts', url: 'http://localhost:5001/graphql' },
{ name: 'reviews', url: 'http://localhost:5002/graphql' },
{ name: 'products', url: 'http://localhost:5003/graphql' },
{ name: 'inventory', url: 'http://localhost:5004/graphql' },
],
}),
debug: true,
});
(async () => {
const server = new ApolloServer({ gateway });
const { url } = await startStandaloneServer(server, {
listen: { port: 5000 },
});
console.log(`🚀 Server ready at: ${url}`);
})();