1

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

Furkan Gulsen
  • 1,384
  • 2
  • 12
  • 24

1 Answers1

-2

if you work with apollo federation on server you call.