Skip to content

fix: Fixes Could not find a resolve function runtime error when returning Union types - #22

Merged
NeedleInAJayStack merged 2 commits into
mainfrom
fix/populate-isTypeOf
Nov 15, 2026
Merged

NeedleInAJayStack merged 2 commits into
mainfrom
fix/populate-isTypeOf

Conversation

@NeedleInAJayStack

@NeedleInAJayStack NeedleInAJayStack commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

This fixes an issue where, when a Union was returned, the underlying GraphQL executor couldn't find the concrete type (and therefore concrete type resolver), resulting in a runtime Could not find a resolve function error. Depends on GraphQLSwift/GraphQL#189

@GNMoseke GNMoseke left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is kind magic but IIUC:

when generating the actual swift source for the GraphQLObjectType, you must override the isTypeOf closure to match on the procotol for the union types rather than trying to match on a concrete, since the actual resolver definition only deals in the protocol?

@NeedleInAJayStack

Copy link
Copy Markdown
Member Author

This one is kind magic but IIUC:

when generating the actual swift source for the GraphQLObjectType, you must override the isTypeOf closure to match on the procotol for the union types rather than trying to match on a concrete, since the actual resolver definition only deals in the protocol?

@GNMoseke Yeah, GraphQL's Union type resolution happens here, where it finds the first conforming types whose isTypeOf is not null and returns true. If none match, we get the Could not find a resolve function error. The GraphQL repo leaves defining isTypeOf to the one creating the GraphQLObjectType because it doesn't require strong Swift type mappings.

It was a bug in this package that we didn't populate isTypeOf at all, and just left it as the nil default. As an example, Graphiti does it here.

This fixes an issue where, when a Union was returned, the underlying GraphQL executor couldn't find the concrete type (and therefore concrete type resolver), resulting in a runtime `Could not find a resolve function` error. Depends on GraphQLSwift/GraphQL#189
This is a recreator for the "Could not find a resolve function" issue.
@NeedleInAJayStack
NeedleInAJayStack merged commit 0daec49 into main Nov 15, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants