This could be quite new to everyone but hoping for the best to find out the solution.
I've been trying to setup apollo managed federation through ApolloGateway for federated my services by following the official documentation. https://www.apollographql.com/docs/graph-manager/managed-federation/setup/#4-deploy-the-modified-gateway
.env
NODE_ENV=development
APOLLO_KEY=service:service_name:hash
ApolloGateway
import 'reflect-metadata';
import express from 'express';
import {ApolloServer} from 'apollo-server-express';
import {ApolloGateway} from '@apollo/gateway';
import {config} from 'dotenv';
config();
const port = process.env.NODE_PORT || 7000;
const nodeEnv = process.env.NODE_ENV || 'localhost';
const nodeHost = process.env.NODE_HOST || 'http://localhost';
const apolloGatewayConfig: any = {
__exposeQueryPlanExperimental: false,
};
if (nodeEnv === 'localhost' || true) {
apolloGatewayConfig.serviceList = [
{
name: 'vendors',
url: `${process.env.GMS_VENDORS_NODE_HOST}/graphql`,
}
];
}
const gateway = new ApolloGateway(apolloGatewayConfig);
(async () => {
const app = express();
app.get('/health', (_, res: any): void => {
res.send({gateway: true});
});
const {schema, executor} = await gateway.load(); // breaking point
const server = new ApolloServer({
schema,
executor,
engine: true,
subscriptions: false,
});
server.applyMiddleware({app, path: '/graphql'});
app.listen({port}, () =>
console.log(`API Gateway is ready at ${nodeHost}:${port}`)
);
})();
at line const {schema, executor} = await gateway.load();
it throws an error
UnhandledPromiseRejectionWarning: Error: When
serviceListis not set, an Apollo Engine configuration must be provided.
I've been following official docs but not sure what am I missing here?