Description
Is your feature request related to a problem? Please describe.
Kind of. I need to be able to resolve a Shopper on an Order type, and I have defined this within my additionalTypeDefs
:
extend type Order {
shopper: Shopper
@resolveTo(
sourceName: "Shopper"
sourceTypeName: "Query"
sourceFieldName: "shopperById"
requiredSelectionSet: "{ driverId }"
sourceArgs: { id: "{root.driverId}" }
)
}
It works great when there is a driver/shopper assigned to the order, but that's not always the case.
This seems like it will always run even though the driverId
(required by the shopperById
query) may not be present, causing 404 errors from the underlying API. At first I thought that requiredSelectionSet
handled this validation, but that doesn't seem to be the case.
Describe the solution you'd like
Some way within the resolveTo
return null for the Shopper type if the necessary args are not provided.
Describe alternatives you've considered
This is a non-starter for my usage if this isn't possible, as I am hoping to migrate a codebase where we have many nullable resolved objects/fields.
Additional context
I am using GraphQL Mesh for a BFF layer that depends on swagger docs of microservies that I do not manage, so changing the underlying APIs are not an option. I feel this is something that should be configurable.