How to check to which service is being queried by Apollo Gateway

How to check to which service is being queried by Apollo Gateway


0

I have two services in my Apollo Gateway configuration. I can only connect to one of them with a VPN. I would like to check this using the X-Forwarded-For header.

public makeGateway = (): ApolloGateway => {
    const gateway = new ApolloGateway({
      debug: this.config.DEBUG,
      supergraphSdl: new IntrospectAndCompose({
        subgraphs: this.config.services,
      }),
      buildService: this.buildService,
      serviceHealthCheck: true,
    });
    return gateway;
  };

private willSendRequest = async (
    options: GraphQLDataSourceProcessOptions
  ) => {
    await this.setAuthorizationHeader(options);
  };

  private buildService = ({
    url,
  }: ServiceEndpointDefinition): RemoteGraphQLDataSource<
    Record<string, any>
  > => {
    return new RemoteGraphQLDataSource({
      url,
      willSendRequest: this.willSendRequest,
    });
  };

Unfortunately, I do not know how to get information about the currently used service/endpoint from the above methods.
I tried calling console.log on the url in willSendRequest by passing it from the buildService, but it prints both addresses.


Load 4 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *