federation
federation copied to clipboard
Unable to add an interface extending an entity interface without breaking dependent subgraphs
Issue Description
Consider these subgraphs:
Products | Reviews |
---|---|
|
|
I would expect this to compose ok, because the gateway should understand that all PhysicalProduct
objects are also Product
objects, so resolving reviews
on them should be possible via the reviews subgraph. However, attempting to compose the above results in an error:
Interface field "Product.reviews" is declared in but type "PhysicalProduct", which implements "Product" only in subgraph "products" does not have field "reviews".
This can be worked around by instead declaring the following in the reviews subgraph:
type Product @key(fields: "id") @interfaceObject {
id: String!
reviews: [Review] @shareable
}
type PhysicalProduct @key(fields: "id") @interfaceObject {
id: String!
reviews: [Review] @shareable
}
But this solution is pretty undesirable, since it means that we can't actually separate concerns between the two subgraphs (as the reviews subgraph needs to be aware of all interfaces extending Product
in the products subgraph instead of just the Product
interface).
Link to Reproduction
https://codesandbox.io/p/devbox/stoic-jennings-dmtcpt?workspaceId=f349a0f5-d280-4992-b1d5-8f95a3bc8dda