0

I have three microservices: Service A, Service B, and Service C in Apollo GraphQl Federation. All services have database models which are Model A, Model B, Model C. Every service has its own DB.

Model A has a field bIds that holds ID array of B model. Model B has a field cIds that holds ID array of C model.

I write a query which returns list of A. In every A has list of B and every element of B has list of C.

Schema (typeDef) of Service A:

type A @key(fields: "id") {
  id: ID!
  bIds: [ID]
}

Schema of Service B:

type B @key(fields: "id") {
  id: ID!
  cIds: [ID]
}
extend type A @key(fields: "id") {
  id: ID! @external
  bList: [B]
}

Schema of Service C:

type C @key(fields: "id") {
  id: ID!
}
extend type B @key(fields: "id") {
  id: ID! @external
  cList: [C]
}

It is simple. My problem is that I want a field in Model A which returns list of Model C which consist all cList elements of bList something like that:

extend type A @key(fields: "id") {
  id: ID! @external
  bList: [B]
  derivedCList: [C] @requires(fields: "bList")
}

Resolver of derivedCList must fetch bList frield from A. How can I implement it? fields of @requires need to be @external. bList is not external. It has resolver in the Service B. If I extend type A in Service B with bList field which has @external declerative, Apollo throws exception about it.

Efe AYDIN
  • 193
  • 12

1 Answers1

0

Maybe this should be a feature request for Apollon Federation? It looks feasible to me to add @external to bList, as it's external to C.

rü-
  • 2,129
  • 17
  • 37