Apollo Federation: Local development of an underlying service while extending types

179 views Asked by At

When doing local development on distributed services with Apollo federation, I’ve hit a snag. The problem is when Service 1 defines Type A and Service 2 extends Type A. When running just Service 2 (not the gateway), any operations returning Type A don’t work because it’s not defined in Service 1; Service 2 has no knowledge of Service 1 when running outside the context of the gateway.

I have my stub of Type A in Service 2, but don’t have it available in the query type because it will throw a schema validation error while defeating due to the type already existing in Service 1.

Information on this seems pretty sparse, but perhaps I’m just not connecting the dots. What pattern do you use to handle this problem?

edit Example code

Service 1 - types

`
type A @key(fields: "id"){
  id: Int!
  name: string
}

query {
  a(id: Int!): A!
}
`

Service 2 - types

`
extend type A @key(fields: "id"){
  id: Int! @external
  favoriteNumber: Int!
}
`

The query against the federated gateway:

query {
  a(id: 1) {
    name
    favoriteNumber
  }
}

I’m trying to figure out how to query the entity in Service 2 alone.

0

There are 0 answers