Skip to content

Errors with inputs using extended generics #2267

@shepherd85

Description

@shepherd85

I'm trying to write some filter input classes, but it throws errors when generic types include "extends":

public class Filter<FieldType> {
  public FieldType value;
  public FieldType[] values;
  public Operator op=Operator.EQUAL;

  public Predicate toPredicate(...) {
    ... create a predicate ...
  }
}

public class StringFilter extends Filter<String> { // Works
  @Override
  public Predicate toPredicate(...) {
    ... custom predicate options for strings specifically ...
    ... or super.toPredicate(...) ...
  }
}


public class NumberFilter<NumberType extends Number> extends Filter<NumberType> {
  @Override
  public Predicate toPredicate(...) {
    ... custom predicate options for number types specifically ...
    ... or super.toPredicate(...) ...
  }
}

public class IntFilter extends Filter<Integer> {} // works
public class IntFilter extends NumberFilter<Integer> {} // but this one errors:
// io.smallrye.graphql.schema.SchemaBuilderException: 
//   Don't know what to do with [FieldType] of kind [TYPE_VARIABLE] as parent object reference doesn't contain necessary info: 
// Reference{
//   className=<pkg>.v1.query.filters.IntFilter,
//   name=IntFilterInput,
//   type=INPUT,
//   graphQLClassName=null,
//   adaptTo=null,
//   adaptWith=null, 
//   directiveInstances=null,
//   classParametrizedTypesnull,
//   extendedClassParametrizedTypes{
//     NumberType=Reference{
//       className=java.lang.Integer, 
//       name=Int,
//       type=SCALAR,
//       graphQLClassName=java.lang.Integer,
//       adaptTo=null,
//       adaptWith=null, 
//       directiveInstances=null,
//       classParametrizedTypesnull,
//       extendedClassParametrizedTypesnull,
//       wrapper=null
//     }
//   }, wrapper=null
// }

Is this a bug, or is there a better way to handle this scenario, without boilerplate code for each number scalar?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions