Having problem with removeDirectivesFromDocument

I’m having a problem with removeDirectivesFromDocument. I am trying to write an app that accesses multiple graphql endpoints and am trying to use the code in https://github.com/habx/apollo-multi-endpoint-link, There is no complete working test case with this code so I’m creating one in an nx workspace. The multi-endpoint-link uses a directive to define which endpoint a query should be sent to. My test case is currently failing and in stepping through the code it appears that removeDirectivesFromDocument is being called to remove the directive before sending it to the endpoint but the query being returned by this call still contains the directive. The query looks like:

const query = gql`

query Rates @api(contextKey: "apiName") {

  rates(currency: "USD") {

    currency

    ratep

  }

}

`;

The call to remove the directive looks like:

const query = removeDirectivesFromDocument(
[{ name: ‘api’, remove: true }],
operation.query
)

I’m using apollo client" 3.4.10. Is anyone else using this API, is it working for you?

Any suggestions on the best way to debug or suggestions on better ways to support multiple endpoints would be much appreciated

@mwoodpatrick removeDirectivesFromDocument doesn’t currently support removing directives from operation definitions, so it won’t touch query Rates @api(contextKey: "apiName"). We’d be open to a PR for this if you’re interested.