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.