apollographql / apollographql/federation
Gateway V2 throws "non nullable" error for extended type fields that exist
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 727
- Forks
- 276
- Avg merge
- 1h 47m
- Merged PRs (30d)
- 1
Description
## Summary:
Hey guys 👋 !
I have been trying to upgrade our Apollo Gateway version to V2 through our gateways here at Neo. Most of the changes were backwards compatible as expected. However, we ran into one bug related to resolving extended type fields under an interface list.
Ive set up a super simplified demo of the problem here https://github.com/heramb-sawant/federation-demo.
### Setup:
Service 1 - Product Graph
```graphql
extend type Query {
queryInterfaceType(first: Int = 5): [QueryInterfaceType!]!
}
interface QueryInterfaceType {
id: String!
typeUnderInterface: [TypeUnderInterface!]!
}
type FirstInterface implements QueryInterfaceType {
id: String!
typeUnderInterface: [TypeUnderInterface!]!
}
type SecondInterface implements QueryInterfaceType {
id: String!
typeUnderInterface: [TypeUnderInterface!]!
}
type TypeUnderInterface @key(fields: "externalRefKey") {
externalRefKey: String!
nonKeyExternalRef: Float!
}
```
Service 2 - Inventory Graph
```graphql
extend type TypeUnderInterface @key(fields: "externalRefKey") {
externalRefKey: String! @external
nonKeyExternalRef: Float! @external
fieldFromOtherService: String! @requires(fields: "nonKeyExternalRef")
}
```
### Reproduction:
When querying this graph, if you don't query the interface types directly everything works as expected.
```graphql
query Query {
queryInterfaceType {
id
typeUnderInterface {
externalRefKey
nonKeyExternalRef
fieldFromOtherService
}
}
}
```
When querying types specific on the interface, we get the "non nullable" error
```graphql
query Query {
queryInterfaceType {
... on FirstInterface {
id
typeUnderInterface {
externalRefKey
nonKeyExternalRef
fieldFromOtherService
}
}
... on SecondInterface {
id
typeUnderInterface {
externalRefKey
nonKeyExternalRef
fieldFromOtherService
}
}
}
}
```
The expectation is to be able to run both queries with no problems.
The demo is running on `"@apollo/gateway": "2.1.3"` but if you downgrade to our current version `"@apollo/gateway": "0.51.0"`. This demo works as expected.
Please let me know if there are any other details I could provide!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked federation-demo reproduction and compare @apollo/gateway 2.1.3 against 0.51.0, running both queries described in the issue. Trace the gateway's query planning and execution for interface fragments, extended fields, and @requires; done means both queries complete without a non-nullability error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100