Cross-referencing a type with Apollo Federation across multiple sub-graphs

108 Views Asked by At

I am new to Apollo Federation and I am having the following issue / question:

In Subgraph A I have the following:

type Product @key(fields: "id") { {
   id: ID!
   title: String
}

In Subgraph B I have the following:

type Product @key(fields: "id") { {
   id: ID!
   related: [Product]
}

When I run my query like this:

query Product($productId: ID!) {
  product(id: $productId) {
    id
    title
    related {
      id
    }
  }
}

I am getting the expected results, but as soon as I now want to also get the title values for the related, i.e. when running such query

query Product($productId: ID!) {
  product(id: $productId) {
    id
    title
    related {
      id
      title
    }
  }
}

I start seeing the following error "Cannot return null for non-nullable field Product.title."

Any ideas, into which keywords to look or what I might be missing here to get the title value for related products from Service A?

Was reading some further Apollo Federation materials and looking out for some more examples, but did not really find any good pointer unfortunately.

0

There are 0 best solutions below