This fixes a bug when interface for schema types are generated along with the generateInterfaces = true for data types. As a result, the interfaces generated for data types are used in the JsonSubType annotations which do not deserialize due to lack of constructor.
interface Fruit {
seeds: [Seed]
}
type Apple implements Fruit {
seeds: [Seed]
truth: Boolean!
}
type Seed {
shape: String
}
The above schema before the fix would produce 3 interfaces - IFruit, IApple and ISeed when generateInterfaces = true.
IFruit has the JsonSubTypes set to IApple and ISeed interface classes instead of Apple and Seed which are the concrete types.
Because of this issue, jackson cannot properly deserialize into the interface type IFruit. After the fix, the annotations are now:
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "__typename"
)
@JsonSubTypes(@JsonSubTypes.Type(value = Apple.class, name = "Apple"))
public interface Fruit {
List<? extends ISeed> getSeeds();
void setSeeds(List<? extends ISeed> seeds);
}
Note the value is set to Apple.class instead of IApple.class
This fixes a bug when interface for schema types are generated along with the
generateInterfaces = true
for data types. As a result, the interfaces generated for data types are used in the JsonSubType annotations which do not deserialize due to lack of constructor.The above schema before the fix would produce 3 interfaces - IFruit, IApple and ISeed when generateInterfaces = true. IFruit has the JsonSubTypes set to IApple and ISeed interface classes instead of Apple and Seed which are the concrete types.
Because of this issue, jackson cannot properly deserialize into the interface type IFruit. After the fix, the annotations are now:
Note the value is set to
Apple.class
instead ofIApple.class