Skip to content

getPropertyViaFieldAccess ignoring superclass fields #3019

@AlexanderPraegla

Description

@AlexanderPraegla

Describe the bug
When an abstract class with Lomboks fluent accesssors is defined, graphql.schema.PropertyFetchingImpl#getPropertyViaFieldAccess will not find the field because it does not check the superclass like e.g. graphql.schema.PropertyFetchingImpl#findPubliclyAccessibleMethod. This results in a null value in the query response for data that is acutally available.

To Reproduce
Use this schema:

type Query {
    movies: [Movie]
}

interface Movie {
    title: String
}

type ScaryMovie implements Movie {
    title: String
    gory: Boolean
    scareFactor: Int
}

type ActionMovie implements Movie {
    title: String
    nrOfExplosions: Int
}

Implement the classes like this:

@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(fluent = true)
public abstract class Movie {
    private String title;

}

@Data
@Accessors(fluent = true)
public class ActionMovie extends Movie {
    private int nrOfExplosions;

    public ActionMovie(final String title, int nrOfExplosions) {
        super(title);
        this.nrOfExplosions = nrOfExplosions;
    }
}

@Data
@Accessors(fluent = true)
public class ScaryMovie extends Movie {
    private boolean gory;
    private int scareFactor;

    public ScaryMovie(final String title, final boolean gory, final int scareFactor) {
        super(title);
        this.gory = gory;
        this.scareFactor = scareFactor;
    }

}

I created a simple project to demonstrate this: https://github.com/AlexanderPraegla/graphql-java-lombok-fluent-accessor

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