Consider the following federated GraphQL type structure:
type BaseType {
items: [SomeType!]!
}
type SomeType {
id: ID!
someRelation: SomeOtherTypeFromAnotherGraph! // this is resolved by a federated type resolver through another graph
}
type SomeOtherTypeFromAnotherGraph {
id: ID!
}
When the federated type resolver for SomeOtherTypeFromAnotherGraph returns null for one SomeType in BaseType.items the whole request fails as items elements are non-nullable.
In the context of graceful degradation it might be preferable to just drop items in a list that could not resolved because a federated type resolver returned null for a contained entity: imagine you have a list of teaser images you want to show but 1 is currently broken because of eventual consistency across your services - you still want to show the remaining images.
Currently there is no way to configure this behaviour and the only workaround is to make the inner type of items nullable and have the client do the filtering manually, which feels quite cumbersome.
It would be nice to have a directive to configure this behaviour. The biggest downside in this regard is the high specificity of this feature requests: this only works on lists / arrays of elements that contain a federated / combined type.
In the old age of REST this would be done in a custom aggregation service / BFF which is mostly obsolete in the context of federated GraphQL which sadly lacks a feature to compensate.
P.S: I also feel like the documentation of the current handling is lacking or did I skip over it in the official docs?
Consider the following federated GraphQL type structure:
When the federated type resolver for
SomeOtherTypeFromAnotherGraph
returnsnull
for oneSomeType
inBaseType.items
the whole request fails asitems
elements are non-nullable. In the context of graceful degradation it might be preferable to just drop items in a list that could not resolved because a federated type resolver returned null for a contained entity: imagine you have a list of teaser images you want to show but 1 is currently broken because of eventual consistency across your services - you still want to show the remaining images.Currently there is no way to configure this behaviour and the only workaround is to make the inner type of
items
nullable and have the client do the filtering manually, which feels quite cumbersome.It would be nice to have a directive to configure this behaviour. The biggest downside in this regard is the high specificity of this feature requests: this only works on lists / arrays of elements that contain a federated / combined type.
In the old age of REST this would be done in a custom aggregation service / BFF which is mostly obsolete in the context of federated GraphQL which sadly lacks a feature to compensate.
P.S: I also feel like the documentation of the current handling is lacking or did I skip over it in the official docs?