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

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


0

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.

Share

New contributor

user22407290 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


Load 3 more related questions


Show fewer related questions

0

Reset to default



Browse other questions tagged

or ask your own question.

Leave a Reply

Your email address will not be published. Required fields are marked *