Mutation Input Split Across Two Apollo GraphQL Federated Services

Viewed 229

I have a mutation in my Graph that uses two datasources. We are migrating one of the datasources out to a federated service. That datasource in the federated service uses a portion of the input from the mutation being called. The originating service also uses a portion of the input. For example:

mutation($verifyUserInput: VerifyUserInput!) {
  verifyUser(input: $verifyUserInput) {
    user {
      specialId
    }
    otherServiceField
  }
}

I need to pass part of the VerifyUserInput to the other service that is not the PK for the entity. I can't find the input in the __resolveReference function reference (obviously since reference only passes the typename and PK), context, or info args. Is the original input to the mutation available in the federated service? If so how can I retrieve it?

1 Answers

I ended up sniffing for the exact input I needed on every request in the gateway and adding that value to a header so it could propagate across the services. This definitely feels like a hack. I assume there is a more correct way to do this in Apollo Federation.

Related