apolloGateway cannot connect to graphql express service #6693
-
I ran a service using apolloGateway: export const server = async () => {
const app = express();
const services = [ { name: "product-service", url: "http://localhost:4001/graphql" }];
const availableServices: any[] = [];
const gateway = new ApolloGateway({
serviceList: services,
buildService: ({ name, url }) => {
return new RemoteGraphQLDataSource({
url,
});
},
});
const server = new ApolloServer({
subscriptions: false,
gateway,
});
await server.start();
server.applyMiddleware({ app });
return app.listen(3000);
}; Then I ran a service called product using Graphql-express: export const server = async () => {
const schema = await buildSchema({
resolvers: [__dirname + "/api/**/*.resolver.ts"],
emitSchemaFile: path.resolve(__dirname, `../schema.gql`),
authChecker: authChecker,
});
const app = express();
const server = new ApolloServer({
schema,
context: (ctx: Context) => {
const context = ctx;
return context;
},
});
await server.start();
server.applyMiddleware({
app,
});
return app.listen(4001);
}; Here I am getting an error on the api-gateway side to connect: Error checking for changes to service definitions: Couldn't load service definitions for "product-service" at http://localhost:4001/graphql: 400: Bad Request |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I suspect you're more likely to find help if you provide your reproduction as fully self-contained, eg a git repo that can be cloned or a codesandbox.io sandbox. Otherwise a lot of guesswork goes into the software versions you've chosen and it can be hard to nail down the real problem. This is also more appropriate for https://github.com/apollographql/federation as all the relevant logic is maintained in that project. |
Beta Was this translation helpful? Give feedback.
I suspect you're more likely to find help if you provide your reproduction as fully self-contained, eg a git repo that can be cloned or a codesandbox.io sandbox. Otherwise a lot of guesswork goes into the software versions you've chosen and it can be hard to nail down the real problem. This is also more appropriate for https://github.com/apollographql/federation as all the relevant logic is maintained in that project.