gql icon indicating copy to clipboard operation
gql copied to clipboard

[gql] always return empty array when input [type!] is null

Open GwonHyeok opened this issue 5 years ago • 0 comments

schema.graphql

input IntFilter {
    equals: Int
    gt: Int
    gte: Int
    in: [Int!]
    lt: Int
    lte: Int
    not: NestedIntFilter
    notIn: [Int!]
}

On this input, 'in' and 'notIn' are nullable.

However, when these values ​​are null, it always returns an empty list.

I/flutter ( 8596):   vars=GRoundsVars {
I/flutter ( 8596):     where=GRoundWhereInput {
I/flutter ( 8596):       price=GIntFilter {
I/flutter ( 8596):         equals=0,
I/flutter ( 8596):         Gin=[],
I/flutter ( 8596):         notIn=[],
I/flutter ( 8596):       },
I/flutter ( 8596):     },
I/flutter ( 8596):     orderBy=[],
I/flutter ( 8596):   },

schema.ast.gql.dart

const IntFilter = _i1.InputObjectTypeDefinitionNode(
    name: _i1.NameNode(value: 'IntFilter'),
    directives: [],
    fields: [
      _i1.InputValueDefinitionNode(
          name: _i1.NameNode(value: 'equals'),
          directives: [],
          type: _i1.NamedTypeNode(
              name: _i1.NameNode(value: 'Int'), isNonNull: false),
          defaultValue: null),
      _i1.InputValueDefinitionNode(
          name: _i1.NameNode(value: 'gt'),
          directives: [],
          type: _i1.NamedTypeNode(
              name: _i1.NameNode(value: 'Int'), isNonNull: false),
          defaultValue: null),
      _i1.InputValueDefinitionNode(
          name: _i1.NameNode(value: 'gte'),
          directives: [],
          type: _i1.NamedTypeNode(
              name: _i1.NameNode(value: 'Int'), isNonNull: false),
          defaultValue: null),
      _i1.InputValueDefinitionNode(
          name: _i1.NameNode(value: 'in'),
          directives: [],
          type: _i1.ListTypeNode(
              type: _i1.NamedTypeNode(
                  name: _i1.NameNode(value: 'Int'), isNonNull: true),
              isNonNull: false),
          defaultValue: null),
      _i1.InputValueDefinitionNode(
          name: _i1.NameNode(value: 'lt'),
          directives: [],
          type: _i1.NamedTypeNode(
              name: _i1.NameNode(value: 'Int'), isNonNull: false),
          defaultValue: null),
      _i1.InputValueDefinitionNode(
          name: _i1.NameNode(value: 'lte'),
          directives: [],
          type: _i1.NamedTypeNode(
              name: _i1.NameNode(value: 'Int'), isNonNull: false),
          defaultValue: null),
      _i1.InputValueDefinitionNode(
          name: _i1.NameNode(value: 'not'),
          directives: [],
          type: _i1.NamedTypeNode(
              name: _i1.NameNode(value: 'NestedIntFilter'), isNonNull: false),
          defaultValue: null),
      _i1.InputValueDefinitionNode(
          name: _i1.NameNode(value: 'notIn'),
          directives: [],
          type: _i1.ListTypeNode(
              type: _i1.NamedTypeNode(
                  name: _i1.NameNode(value: 'Int'), isNonNull: true),
              isNonNull: false),
          defaultValue: null)
    ]);

schema.schema.gql.dart

abstract class GIntFilter implements Built<GIntFilter, GIntFilterBuilder> {
  GIntFilter._();

  factory GIntFilter([Function(GIntFilterBuilder b) updates]) = _$GIntFilter;

  @nullable
  int get equals;

  @nullable
  int get gt;

  @nullable
  int get gte;

  @BuiltValueField(wireName: 'in')
  BuiltList<int> get Gin;

  @nullable
  int get lt;

  @nullable
  int get lte;

  @nullable
  GNestedIntFilter get not;

  BuiltList<int> get notIn;

  static Serializer<GIntFilter> get serializer => _$gIntFilterSerializer;

  Map<String, dynamic> toJson() =>
      _i1.serializers.serializeWith(GIntFilter.serializer, this);

  static GIntFilter fromJson(Map<String, dynamic> json) =>
      _i1.serializers.deserializeWith(GIntFilter.serializer, json);
}

I think the nullable annotation is not created for "in" and "notIn" because of this code below.

name: _i1.NameNode(value: 'Int'), isNonNull: true) name: _i1.NameNode(value: 'Int'), isNonNull: true)

GwonHyeok avatar Oct 23 '20 17:10 GwonHyeok