Hello Apollo Community,
I am trying to run apollo federation in k8s locally. Initially i was using supergraphSdl which was just a string of all my graphql queries and mutations. I decided to switch to IntrospectAndCompose
as recommended by the apollo team, but i get this error
Error: Couldn't load service definitions for \"users-service\" at http://users_service:3005/graphql: Cannot read property 'source' of undefined"
I have confirmed that Introspection is set to true in my users subgraph, and it is running fine locally, What could I be doing wrong? Here is an example of my setup
// gateway setup
if (!apolloKey) {
gatewayOptions.supergraphSdl = new IntrospectAndCompose({
subgraphs: [
{ name: "users-service", url: "http://users_service:3005/graphql" },
{ name: "news-service", url: "http://news_service:3011/graphql" },
{
name: "notification-service",
url: "http://notifications_service:3012/graphql",
},
],
})
}
gatewayOptions.buildService = ({ url }) => {
return new AuthenticatedDataSource({ url })
}
const gateway = new ApolloGateway(gatewayOptions)
And my users subgraph has this
const server = new ApolloServer({
context,
schema,
plugins: [ApolloServerPluginDrainHttpServer({ httpServer }), newrelicPlugin].filter(Boolean),
introspection: process.env.NODE_ENV === 'development' ? true : false,
formatError: (error) => {
if (error.originalError instanceof ApolloError) {
return error;
}
const errId = uuidv4();
console.log(error);
logger.error(`${errId} ${error.message}`);
if (Constants.IS_DEV) {
logger.error(error);
return {
message: error.message,
};
}
return new GraphQLError(`Internal error: ${errId}`);
},
});
Any help is appreciated. Thank you!