PropertyFetchingImpl#getPropertyViaFieldAccess
first looks for the field with Class#getField
where it will not find the field because internally it calls Class#privateGetDeclaredFields(publicOnly: true)
. This method does however try to handle if the field is on a superclass
// Direct superclass, recursively
if (!isInterface()) {
Class<?> c = getSuperclass();
if (c != null) {
if ((res = c.getField0(name)) != null) {
return res;
}
}
}
The PropertyFetchingImpl then uses Class#getDeclaredField
to access private fields via setAccessible. The problem is, although that method does call Class#privateGetDeclaredFields(publicOnly: false)
, it does not have any handling to look for the field on the superclass.
As such, Spring for GraphQL can resolve fields like so (without any public getters)
public class MyClass {
private final ImmutableList<Id> ids;
}
but not fields like so (without any public getters)
public abstract class MyAbstractClass {
private final ImmutableList<Id> ids;
}