Skip to content

Support resolvers for supertypes of data classes - #820

Merged
oryan-block merged 3 commits into
masterfrom
bugfix/497
Oct 3, 2026
Merged

oryan-block merged 3 commits into
masterfrom
bugfix/497

Conversation

@oryan-block

Copy link
Copy Markdown
Collaborator

Fixes #497

Checklist

  • Pull requests follows the contribution guide
  • New or modified functionality is covered by tests

Description

A GraphQLResolver<Base> was ignored for a data class Thing extends Base, so building the schema failed with FieldResolverError: No method or field found. The scanner only matched resolvers whose generic type was exactly the data class.

Now it also picks up resolvers for any superclass or interface of the data class. They're searched most specific first, followed by the data class itself. So a ThingResolver method wins over a BaseResolver method, which wins over a resolver for an interface Base implements. MultiResolverInfo takes the concrete data class instead of requiring all resolvers to share one, and each resolver keeps its own type as the expected source parameter, so isActive(base: Base) matches when the source is a Thing.

Resolvers for Object are excluded from the supertype matching, otherwise a GraphQLResolver<Any> would apply to every type.

One behaviour change: a supertype resolver method now takes precedence over a getter on the subclass itself (e.g. BaseResolver.label(Base) over Thing.getLabel()). This is the same precedence that already applies to Base itself.

🤖 Generated with Claude Code

oryan-block and others added 3 commits October 2, 2026 17:59
A GraphQLResolver<Base> is now used for any data class extending or
implementing Base. Resolvers are searched most specific first, followed
by the data class itself.

Fixes #497

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Cover case where a GraphQLResolver<Base> method and a getter on the subclass both match a field
- Move scanQueueItemForPotentialMatches next to related scan methods (no behavior change)
@sonarqubecloud

sonarqubecloud Bot commented Oct 3, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FieldResolverError with resolver for superclass or interface

1 participant