Skip to content

FieldResolverError with resolver for superclass or interface #497

Open
@florensie

Description

@florensie

Description

Consider the following dataclass hierarchy:

abstract class Base {
}

class Thing extends Base {
}

This is a custom resolver for the abstract class Base:

class BaseResolver implements GraphQLResolver<Base> {
    public boolean isActive(Base base) {
       return true;
   }
}

Root query resolver with datafetcher that returns our concrete class Thing:

class RootQueryResolver implements GraphQLQueryResolver {
    public Thing getThing() {
        return new Thing();
    }
}

Expected behavior

The following schema should work fine and return true for queries on the active field:

type Query {
    thing: Thing!
}

type Thing {
    active: Boolean!
}

Actual behavior

graphql.kickstart.tools.resolver.FieldResolverError: No method or field found as defined in schema [...]

Steps to reproduce the bug

  1. Create a resolver for a supertype (class or interface) with any datafetcher
  2. Have a query return a subclass of that type
  3. Try building the schema

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions