The query throws the error Cannot read properties of undefined (reading 'has')
I found out the error is thrown here.
Strangely if I change the returned array order (returning a Recipe before a Post) the error changes to Cannot return null for non-nullable field Post.title. (it works if I only ask for Post.id since it doesn't have to resolve fields from another service)
As per this code comment https://github.com/mercurius-js/mercurius-gateway/blob/main/lib/gateway/make-resolver.js#L652 it seems that it is not possible to define a Query that returns a Union type with one of the included object types defined in another service.
E.g.:
With these two service schemas
and a dummy
search
resolver like this:The query throws the error
Cannot read properties of undefined (reading 'has')
I found out the error is thrown here.Strangely if I change the returned array order (returning a
Recipe
before aPost
) the error changes toCannot return null for non-nullable field Post.title.
(it works if I only ask for Post.id since it doesn't have to resolve fields from another service)