apollographql / apollographql/federation
@interfaceObject example doesn't work
- Dominant language
- TypeScript
- Stars
- 725
- Forks
- 276
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 1
Description
### Issue Description
I was having trouble composing my schema with @interfaceObject, and what I had is almost identical to the [example provided](https://www.apollographql.com/docs/federation/federated-types/interfaces/#example-schemas).
See my reproduction https://github.com/jhanggi/apollo-interface-obj-bug
I get the same errors there, and what's particularly weird is different errors between `rover supergraph compose` and `rover dev`
Any ideas?
Running rover 0.22.0
```
⌛ resolving SDL for subgraphs defined in ./supergraph.yml
🎶 composing supergraph with Federation v2.3.2
HINT: [INCONSISTENT_INTERFACE_VALUE_TYPE_FIELD]: Field "Media.title" of interface type "Media" is defined in some but not all subgraphs that define "Media": "Media.title" is defined in subgraph "graph-a" but not in subgraph "graph-b".
HINT: [INCONSISTENT_INTERFACE_VALUE_TYPE_FIELD]: Field "Media.reviews" of interface type "Media" is defined in some but not all subgraphs that define "Media": "Media.reviews" is defined in subgraph "graph-b" but not in subgraph "graph-a".
```
I thought the whole point of @interfaceObject was that different subgraphs could contribute different fields to an interface.
It appears as if it does successfully generate a schema, though.
Rover dev has a different problem (besides the fact it is ignoring the federation version in supergraph.yml):
```
> rover dev --supergraph-config ./supergraph.yml
⚠️ Do not run this command in production! ⚠️ It is intended for local development.
🛫 starting a session with the 'graph-b' subgraph
🛫 starting a session with the 'graph-a' subgraph
🎶 composing supergraph with Federation v2.6.1
error[E029]: Encountered 1 build error while trying to build a supergraph.
Caused by:
INTERFACE_OBJECT_USAGE_ERROR: Type "Media" is declared with @interfaceObject in all the subgraphs in which is is defined (it is defined in subgraph "graph-b" but should be defined as an interface in at least one subgraph)
```
### Link to Reproduction
https://github.com/jhanggi/apollo-interface-obj-bug
### Reproduction Steps
_No response_
Contributor guide
Research direction
Start with the linked reproduction and its supergraph.yml, then run the reported rover supergraph compose and rover dev commands using the stated versions. Compare the Federation 2.3.2 and 2.6.1 diagnostics and determine the expected @interfaceObject behavior; done means the discrepancy is resolved or clearly documented with a reproducible result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100