From 006e06f2bf35c079b2dd68d1edfc85aaf6ddbabf Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 29 Jan 2023 19:14:10 +0100 Subject: [PATCH 01/10] feat: allow distinguishing between null and absent values --- .../aliased_hero.data.gql.g.dart | 30 +- .../__generated__/aliased_hero.req.gql.g.dart | 8 +- .../__generated__/aliased_hero.var.gql.dart | 46 ++- .../__generated__/aliased_hero.var.gql.g.dart | 52 +-- .../hero_with_fragments.data.gql.g.dart | 75 ++++- .../hero_with_fragments.req.gql.g.dart | 8 +- .../hero_with_fragments.var.gql.dart | 159 ++++++++- .../hero_with_fragments.var.gql.g.dart | 151 +-------- ...terface_subtyped_fragments.data.gql.g.dart | 110 ++++-- ...nterface_subtyped_fragments.req.gql.g.dart | 8 +- ..._interface_subtyped_fragments.var.gql.dart | 175 +++++++++- ...nterface_subtyped_fragments.var.gql.g.dart | 138 +------- .../graphql/__generated__/schema.ast.gql.dart | 46 ++- .../__generated__/schema.schema.gql.dart | 235 ++++++++++++- .../__generated__/schema.schema.gql.g.dart | 312 ++++++++---------- .../__generated__/serializers.gql.dart | 18 +- .../__generated__/serializers.gql.g.dart | 9 +- .../lib/graphql/schema.graphql | 6 + .../hero_for_episode.data.gql.g.dart | 44 ++- .../hero_for_episode.req.gql.g.dart | 8 +- .../hero_for_episode.var.gql.dart | 88 ++++- .../hero_for_episode.var.gql.g.dart | 80 +---- .../hero_no_vars.data.gql.g.dart | 16 +- .../__generated__/hero_no_vars.req.gql.g.dart | 8 +- .../__generated__/hero_no_vars.var.gql.dart | 38 ++- .../__generated__/hero_no_vars.var.gql.g.dart | 26 +- .../review_with_date.data.gql.g.dart | 28 +- .../review_with_date.req.gql.g.dart | 8 +- .../review_with_date.var.gql.dart | 83 ++++- .../review_with_date.var.gql.g.dart | 99 +----- .../create_custom_field.ast.gql.dart | 37 +++ .../create_custom_field.data.gql.dart | 37 +++ .../create_custom_field.data.gql.g.dart | 174 ++++++++++ .../create_custom_field.req.gql.dart | 42 +++ .../create_custom_field.req.gql.g.dart | 180 ++++++++++ .../create_custom_field.var.gql.dart | 80 +++++ .../create_custom_field.var.gql.g.dart | 107 ++++++ .../create_review.data.gql.g.dart | 19 +- .../create_review.req.gql.g.dart | 8 +- .../__generated__/create_review.var.gql.dart | 67 +++- .../create_review.var.gql.g.dart | 73 +--- .../human_with_args.data.gql.g.dart | 16 +- .../human_with_args.req.gql.g.dart | 8 +- .../human_with_args.var.gql.dart | 46 ++- .../human_with_args.var.gql.g.dart | 52 +-- .../lib/variables/create_custom_field.graphql | 5 + codegen/end_to_end_test/pubspec.yaml | 35 ++ .../test/operation/variables_test.dart | 18 +- .../test/schema/input_test.dart | 29 +- .../test/schema/scalars_test.dart | 32 +- codegen/gql_build/README.md | 14 + codegen/gql_build/lib/src/schema_builder.dart | 35 +- .../gql_build/lib/src/serializer_builder.dart | 38 +-- codegen/gql_build/lib/src/utils/writer.dart | 13 +- codegen/gql_build/lib/src/var_builder.dart | 23 +- codegen/gql_build/pubspec.yaml | 35 ++ codegen/gql_code_builder/lib/schema.dart | 14 +- .../gql_code_builder/lib/src/built_class.dart | 4 +- codegen/gql_code_builder/lib/src/common.dart | 36 +- codegen/gql_code_builder/lib/src/schema.dart | 83 +++-- .../lib/src/schema/input.dart | 26 +- codegen/gql_code_builder/lib/var.dart | 267 +++++++++++++-- codegen/gql_code_builder/pubspec.yaml | 35 ++ examples/gql_example_build/pubspec.yaml | 35 ++ examples/gql_example_cli/pubspec.yaml | 35 ++ examples/gql_example_cli_github/pubspec.yaml | 35 ++ examples/gql_example_dio_link/pubspec.yaml | 35 ++ examples/gql_example_flutter/pubspec.yaml | 37 +++ .../gql_example_http_auth_link/pubspec.yaml | 35 ++ gql/pubspec.yaml | 35 ++ gql_pedantic/pubspec.yaml | 35 ++ links/gql_dedupe_link/pubspec.yaml | 35 ++ links/gql_dio_link/pubspec.yaml | 35 ++ links/gql_error_link/pubspec.yaml | 35 ++ links/gql_exec/lib/src/value.dart | 18 + links/gql_exec/lib/value.dart | 1 + links/gql_exec/pubspec.yaml | 35 ++ links/gql_http_link/lib/src/link.dart | 4 + links/gql_http_link/pubspec.yaml | 35 ++ links/gql_link/pubspec.yaml | 35 ++ links/gql_transform_link/pubspec.yaml | 35 ++ links/gql_websocket_link/pubspec.yaml | 35 ++ 82 files changed, 3248 insertions(+), 1137 deletions(-) create mode 100644 codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.ast.gql.dart create mode 100644 codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.data.gql.dart create mode 100644 codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.data.gql.g.dart create mode 100644 codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.req.gql.dart create mode 100644 codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.req.gql.g.dart create mode 100644 codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.dart create mode 100644 codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.g.dart create mode 100644 codegen/end_to_end_test/lib/variables/create_custom_field.graphql create mode 100644 links/gql_exec/lib/src/value.dart create mode 100644 links/gql_exec/lib/value.dart diff --git a/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.data.gql.g.dart b/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.data.gql.g.dart index ed85bfb5..6d82d8a2 100644 --- a/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.data.gql.g.dart +++ b/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.data.gql.g.dart @@ -253,8 +253,12 @@ class _$GAliasedHeroData extends GAliasedHeroData { @override int get hashCode { - return $jf($jc($jc($jc(0, G__typename.hashCode), empireHero.hashCode), - jediHero.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, empireHero.hashCode); + _$hash = $jc(_$hash, jediHero.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -394,9 +398,13 @@ class _$GAliasedHeroData_empireHero extends GAliasedHeroData_empireHero { @override int get hashCode { - return $jf($jc( - $jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode), - from.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, from.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -542,9 +550,13 @@ class _$GAliasedHeroData_jediHero extends GAliasedHeroData_jediHero { @override int get hashCode { - return $jf($jc( - $jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode), - from.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, from.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -638,4 +650,4 @@ class GAliasedHeroData_jediHeroBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.req.gql.g.dart b/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.req.gql.g.dart index 34ca12f5..3c44d30b 100644 --- a/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.req.gql.g.dart +++ b/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.req.gql.g.dart @@ -90,7 +90,11 @@ class _$GAliasedHero extends GAliasedHero { @override int get hashCode { - return $jf($jc($jc(0, vars.hashCode), operation.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -167,4 +171,4 @@ class GAliasedHeroBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.dart b/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.dart index fa90a01c..bdaa5b89 100644 --- a/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.dart +++ b/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.dart @@ -19,8 +19,6 @@ abstract class GAliasedHeroVars _$GAliasedHeroVars; _i1.GEpisode get ep; - static Serializer get serializer => - _$gAliasedHeroVarsSerializer; Map toJson() => (_i2.serializers.serializeWith( GAliasedHeroVars.serializer, this, @@ -30,4 +28,48 @@ abstract class GAliasedHeroVars GAliasedHeroVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GAliasedHeroVarsSerializer(); +} + +class GAliasedHeroVarsSerializer + extends StructuredSerializer { + final String wireName = 'GAliasedHeroVars'; + + final Iterable types = const [GAliasedHeroVars, _$GAliasedHeroVars]; + + Iterable serialize( + Serializers serializers, + GAliasedHeroVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('ep'); + result.add(serializers.serialize(object.ep, + specifiedType: const FullType(_i1.GEpisode))); + return result; + } + + GAliasedHeroVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GAliasedHeroVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'ep': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; + builder.ep = fieldValue; + break; + } + } + return builder.build(); + } } diff --git a/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.g.dart b/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.g.dart index f40c47cc..eb6a4801 100644 --- a/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.g.dart @@ -6,51 +6,6 @@ part of 'aliased_hero.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** -Serializer _$gAliasedHeroVarsSerializer = - new _$GAliasedHeroVarsSerializer(); - -class _$GAliasedHeroVarsSerializer - implements StructuredSerializer { - @override - final Iterable types = const [GAliasedHeroVars, _$GAliasedHeroVars]; - @override - final String wireName = 'GAliasedHeroVars'; - - @override - Iterable serialize(Serializers serializers, GAliasedHeroVars object, - {FullType specifiedType = FullType.unspecified}) { - final result = [ - 'ep', - serializers.serialize(object.ep, - specifiedType: const FullType(_i1.GEpisode)), - ]; - - return result; - } - - @override - GAliasedHeroVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = new GAliasedHeroVarsBuilder(); - - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current! as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'ep': - result.ep = serializers.deserialize(value, - specifiedType: const FullType(_i1.GEpisode))! as _i1.GEpisode; - break; - } - } - - return result.build(); - } -} - class _$GAliasedHeroVars extends GAliasedHeroVars { @override final _i1.GEpisode ep; @@ -79,7 +34,10 @@ class _$GAliasedHeroVars extends GAliasedHeroVars { @override int get hashCode { - return $jf($jc(0, ep.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, ep.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -132,4 +90,4 @@ class GAliasedHeroVarsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.data.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.data.gql.g.dart index 405b7551..b5005f79 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.data.gql.g.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.data.gql.g.dart @@ -691,7 +691,11 @@ class _$GHeroWithFragmentsData extends GHeroWithFragmentsData { @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), hero.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, hero.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -819,10 +823,13 @@ class _$GHeroWithFragmentsData_hero extends GHeroWithFragmentsData_hero { @override int get hashCode { - return $jf($jc( - $jc($jc($jc(0, G__typename.hashCode), id.hashCode), - friendsConnection.hashCode), - name.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, friendsConnection.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -965,8 +972,12 @@ class _$GHeroWithFragmentsData_hero_friendsConnection @override int get hashCode { - return $jf($jc($jc($jc(0, G__typename.hashCode), totalCount.hashCode), - edges.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, totalCount.hashCode); + _$hash = $jc(_$hash, edges.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1108,7 +1119,11 @@ class _$GHeroWithFragmentsData_hero_friendsConnection_edges @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), node.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, node.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1247,7 +1262,11 @@ class _$GHeroWithFragmentsData_hero_friendsConnection_edges_node @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), name.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1355,7 +1374,11 @@ class _$GheroDataData extends GheroDataData { @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), name.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1469,9 +1492,13 @@ class _$GcomparisonFieldsData extends GcomparisonFieldsData { @override int get hashCode { - return $jf($jc( - $jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode), - friendsConnection.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, friendsConnection.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1610,8 +1637,12 @@ class _$GcomparisonFieldsData_friendsConnection @override int get hashCode { - return $jf($jc($jc($jc(0, G__typename.hashCode), totalCount.hashCode), - edges.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, totalCount.hashCode); + _$hash = $jc(_$hash, edges.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1745,7 +1776,11 @@ class _$GcomparisonFieldsData_friendsConnection_edges @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), node.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, node.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1879,7 +1914,11 @@ class _$GcomparisonFieldsData_friendsConnection_edges_node @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), name.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1950,4 +1989,4 @@ class GcomparisonFieldsData_friendsConnection_edges_nodeBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.req.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.req.gql.g.dart index 2c956ffb..075810ea 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.req.gql.g.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.req.gql.g.dart @@ -96,7 +96,11 @@ class _$GHeroWithFragments extends GHeroWithFragments { @override int get hashCode { - return $jf($jc($jc(0, vars.hashCode), operation.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -173,4 +177,4 @@ class GHeroWithFragmentsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.dart index 97d988ed..c592193e 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.dart @@ -5,7 +5,8 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' - as _i1; + as _i2; +import 'package:gql_exec/value.dart' as _i1; part 'hero_with_fragments.var.gql.g.dart'; @@ -17,18 +18,19 @@ abstract class GHeroWithFragmentsVars [Function(GHeroWithFragmentsVarsBuilder b) updates]) = _$GHeroWithFragmentsVars; - int? get first; - static Serializer get serializer => - _$gHeroWithFragmentsVarsSerializer; - Map toJson() => (_i1.serializers.serializeWith( + _i1.Value? get first; + Map toJson() => (_i2.serializers.serializeWith( GHeroWithFragmentsVars.serializer, this, ) as Map); static GHeroWithFragmentsVars? fromJson(Map json) => - _i1.serializers.deserializeWith( + _i2.serializers.deserializeWith( GHeroWithFragmentsVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GHeroWithFragmentsVarsSerializer(); } abstract class GheroDataVars @@ -38,16 +40,17 @@ abstract class GheroDataVars factory GheroDataVars([Function(GheroDataVarsBuilder b) updates]) = _$GheroDataVars; - static Serializer get serializer => _$gheroDataVarsSerializer; - Map toJson() => (_i1.serializers.serializeWith( + Map toJson() => (_i2.serializers.serializeWith( GheroDataVars.serializer, this, ) as Map); static GheroDataVars? fromJson(Map json) => - _i1.serializers.deserializeWith( + _i2.serializers.deserializeWith( GheroDataVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => GheroDataVarsSerializer(); } abstract class GcomparisonFieldsVars @@ -58,16 +61,144 @@ abstract class GcomparisonFieldsVars [Function(GcomparisonFieldsVarsBuilder b) updates]) = _$GcomparisonFieldsVars; - int? get first; - static Serializer get serializer => - _$gcomparisonFieldsVarsSerializer; - Map toJson() => (_i1.serializers.serializeWith( + _i1.Value? get first; + Map toJson() => (_i2.serializers.serializeWith( GcomparisonFieldsVars.serializer, this, ) as Map); static GcomparisonFieldsVars? fromJson(Map json) => - _i1.serializers.deserializeWith( + _i2.serializers.deserializeWith( GcomparisonFieldsVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GcomparisonFieldsVarsSerializer(); +} + +class GHeroWithFragmentsVarsSerializer + extends StructuredSerializer { + final String wireName = 'GHeroWithFragmentsVars'; + + final Iterable types = const [ + GHeroWithFragmentsVars, + _$GHeroWithFragmentsVars + ]; + + Iterable serialize( + Serializers serializers, + GHeroWithFragmentsVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + final _$firstvalue = object.first; + if (_$firstvalue != null) { + result.add('first'); + result.add(serializers.serialize(_$firstvalue!.value, + specifiedType: const FullType(int))); + } + return result; + } + + GHeroWithFragmentsVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GHeroWithFragmentsVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'first': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + builder.first = _i1.Value(fieldValue); + break; + } + } + return builder.build(); + } +} + +class GheroDataVarsSerializer extends StructuredSerializer { + final String wireName = 'GheroDataVars'; + + final Iterable types = const [GheroDataVars, _$GheroDataVars]; + + Iterable serialize( + Serializers serializers, + GheroDataVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + return result; + } + + GheroDataVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GheroDataVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + + } + } + return builder.build(); + } +} + +class GcomparisonFieldsVarsSerializer + extends StructuredSerializer { + final String wireName = 'GcomparisonFieldsVars'; + + final Iterable types = const [ + GcomparisonFieldsVars, + _$GcomparisonFieldsVars + ]; + + Iterable serialize( + Serializers serializers, + GcomparisonFieldsVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + final _$firstvalue = object.first; + if (_$firstvalue != null) { + result.add('first'); + result.add(serializers.serialize(_$firstvalue!.value, + specifiedType: const FullType(int))); + } + return result; + } + + GcomparisonFieldsVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GcomparisonFieldsVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'first': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + builder.first = _i1.Value(fieldValue); + break; + } + } + return builder.build(); + } } diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.g.dart index f1550823..08041e98 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.g.dart @@ -6,132 +6,9 @@ part of 'hero_with_fragments.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** -Serializer _$gHeroWithFragmentsVarsSerializer = - new _$GHeroWithFragmentsVarsSerializer(); -Serializer _$gheroDataVarsSerializer = - new _$GheroDataVarsSerializer(); -Serializer _$gcomparisonFieldsVarsSerializer = - new _$GcomparisonFieldsVarsSerializer(); - -class _$GHeroWithFragmentsVarsSerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - GHeroWithFragmentsVars, - _$GHeroWithFragmentsVars - ]; - @override - final String wireName = 'GHeroWithFragmentsVars'; - - @override - Iterable serialize( - Serializers serializers, GHeroWithFragmentsVars object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - Object? value; - value = object.first; - if (value != null) { - result - ..add('first') - ..add(serializers.serialize(value, specifiedType: const FullType(int))); - } - return result; - } - - @override - GHeroWithFragmentsVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = new GHeroWithFragmentsVarsBuilder(); - - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current! as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'first': - result.first = serializers.deserialize(value, - specifiedType: const FullType(int)) as int?; - break; - } - } - - return result.build(); - } -} - -class _$GheroDataVarsSerializer implements StructuredSerializer { - @override - final Iterable types = const [GheroDataVars, _$GheroDataVars]; - @override - final String wireName = 'GheroDataVars'; - - @override - Iterable serialize(Serializers serializers, GheroDataVars object, - {FullType specifiedType = FullType.unspecified}) { - return []; - } - - @override - GheroDataVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - return new GheroDataVarsBuilder().build(); - } -} - -class _$GcomparisonFieldsVarsSerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - GcomparisonFieldsVars, - _$GcomparisonFieldsVars - ]; - @override - final String wireName = 'GcomparisonFieldsVars'; - - @override - Iterable serialize( - Serializers serializers, GcomparisonFieldsVars object, - {FullType specifiedType = FullType.unspecified}) { - final result = []; - Object? value; - value = object.first; - if (value != null) { - result - ..add('first') - ..add(serializers.serialize(value, specifiedType: const FullType(int))); - } - return result; - } - - @override - GcomparisonFieldsVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = new GcomparisonFieldsVarsBuilder(); - - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current! as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'first': - result.first = serializers.deserialize(value, - specifiedType: const FullType(int)) as int?; - break; - } - } - - return result.build(); - } -} - class _$GHeroWithFragmentsVars extends GHeroWithFragmentsVars { @override - final int? first; + final _i1.Value? first; factory _$GHeroWithFragmentsVars( [void Function(GHeroWithFragmentsVarsBuilder)? updates]) => @@ -156,7 +33,10 @@ class _$GHeroWithFragmentsVars extends GHeroWithFragmentsVars { @override int get hashCode { - return $jf($jc(0, first.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, first.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -171,9 +51,9 @@ class GHeroWithFragmentsVarsBuilder implements Builder { _$GHeroWithFragmentsVars? _$v; - int? _first; - int? get first => _$this._first; - set first(int? first) => _$this._first = first; + _i1.Value? _first; + _i1.Value? get first => _$this._first; + set first(_i1.Value? first) => _$this._first = first; GHeroWithFragmentsVarsBuilder(); @@ -266,7 +146,7 @@ class GheroDataVarsBuilder class _$GcomparisonFieldsVars extends GcomparisonFieldsVars { @override - final int? first; + final _i1.Value? first; factory _$GcomparisonFieldsVars( [void Function(GcomparisonFieldsVarsBuilder)? updates]) => @@ -291,7 +171,10 @@ class _$GcomparisonFieldsVars extends GcomparisonFieldsVars { @override int get hashCode { - return $jf($jc(0, first.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, first.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -306,9 +189,9 @@ class GcomparisonFieldsVarsBuilder implements Builder { _$GcomparisonFieldsVars? _$v; - int? _first; - int? get first => _$this._first; - set first(int? first) => _$this._first = first; + _i1.Value? _first; + _i1.Value? get first => _$this._first; + set first(_i1.Value? first) => _$this._first = first; GcomparisonFieldsVarsBuilder(); @@ -342,4 +225,4 @@ class GcomparisonFieldsVarsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.g.dart index c19d7668..20c08793 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.g.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.g.dart @@ -919,7 +919,11 @@ class _$GHeroWithInterfaceSubTypedFragmentsData @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), hero.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, hero.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1052,8 +1056,12 @@ class _$GHeroWithInterfaceSubTypedFragmentsData_hero @override int get hashCode { - return $jf( - $jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1173,8 +1181,12 @@ class _$GheroFieldsFragmentData__base extends GheroFieldsFragmentData__base { @override int get hashCode { - return $jf( - $jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1302,10 +1314,14 @@ class _$GheroFieldsFragmentData__asHuman @override int get hashCode { - return $jf($jc( - $jc($jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode), - homePlanet.hashCode), - friends.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, homePlanet.hashCode); + _$hash = $jc(_$hash, friends.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1449,7 +1465,10 @@ class _$GheroFieldsFragmentData__asHuman_friends__base @override int get hashCode { - return $jf($jc(0, G__typename.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1569,9 +1588,13 @@ class _$GheroFieldsFragmentData__asHuman_friends__asDroid @override int get hashCode { - return $jf($jc( - $jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode), - primaryFunction.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, primaryFunction.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1715,9 +1738,13 @@ class _$GheroFieldsFragmentData__asHuman_friends__asHuman @override int get hashCode { - return $jf($jc( - $jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode), - homePlanet.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, homePlanet.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1853,9 +1880,13 @@ class _$GheroFieldsFragmentData__asDroid @override int get hashCode { - return $jf($jc( - $jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode), - primaryFunction.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, primaryFunction.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1976,8 +2007,12 @@ class _$GhumanFieldsFragmentData extends GhumanFieldsFragmentData { @override int get hashCode { - return $jf($jc($jc($jc(0, G__typename.hashCode), homePlanet.hashCode), - friends.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, homePlanet.hashCode); + _$hash = $jc(_$hash, friends.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -2099,7 +2134,10 @@ class _$GhumanFieldsFragmentData_friends__base @override int get hashCode { - return $jf($jc(0, G__typename.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -2212,9 +2250,13 @@ class _$GhumanFieldsFragmentData_friends__asDroid @override int get hashCode { - return $jf($jc( - $jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode), - primaryFunction.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, primaryFunction.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -2352,9 +2394,13 @@ class _$GhumanFieldsFragmentData_friends__asHuman @override int get hashCode { - return $jf($jc( - $jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode), - homePlanet.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, homePlanet.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -2474,7 +2520,11 @@ class _$GdroidFieldsFragmentData extends GdroidFieldsFragmentData { @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), primaryFunction.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, primaryFunction.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -2539,4 +2589,4 @@ class GdroidFieldsFragmentDataBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.req.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.req.gql.g.dart index b33b976f..39a20488 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.req.gql.g.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.req.gql.g.dart @@ -107,7 +107,11 @@ class _$GHeroWithInterfaceSubTypedFragments @override int get hashCode { - return $jf($jc($jc(0, vars.hashCode), operation.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -190,4 +194,4 @@ class GHeroWithInterfaceSubTypedFragmentsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart index 5993ed7d..265403cb 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart @@ -22,8 +22,6 @@ abstract class GHeroWithInterfaceSubTypedFragmentsVars updates]) = _$GHeroWithInterfaceSubTypedFragmentsVars; _i1.GEpisode get episode; - static Serializer get serializer => - _$gHeroWithInterfaceSubTypedFragmentsVarsSerializer; Map toJson() => (_i2.serializers.serializeWith( GHeroWithInterfaceSubTypedFragmentsVars.serializer, this, @@ -34,6 +32,9 @@ abstract class GHeroWithInterfaceSubTypedFragmentsVars GHeroWithInterfaceSubTypedFragmentsVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GHeroWithInterfaceSubTypedFragmentsVarsSerializer(); } abstract class GheroFieldsFragmentVars @@ -44,8 +45,6 @@ abstract class GheroFieldsFragmentVars [Function(GheroFieldsFragmentVarsBuilder b) updates]) = _$GheroFieldsFragmentVars; - static Serializer get serializer => - _$gheroFieldsFragmentVarsSerializer; Map toJson() => (_i2.serializers.serializeWith( GheroFieldsFragmentVars.serializer, this, @@ -55,6 +54,9 @@ abstract class GheroFieldsFragmentVars GheroFieldsFragmentVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GheroFieldsFragmentVarsSerializer(); } abstract class GhumanFieldsFragmentVars @@ -66,8 +68,6 @@ abstract class GhumanFieldsFragmentVars [Function(GhumanFieldsFragmentVarsBuilder b) updates]) = _$GhumanFieldsFragmentVars; - static Serializer get serializer => - _$ghumanFieldsFragmentVarsSerializer; Map toJson() => (_i2.serializers.serializeWith( GhumanFieldsFragmentVars.serializer, this, @@ -77,6 +77,9 @@ abstract class GhumanFieldsFragmentVars GhumanFieldsFragmentVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GhumanFieldsFragmentVarsSerializer(); } abstract class GdroidFieldsFragmentVars @@ -88,8 +91,6 @@ abstract class GdroidFieldsFragmentVars [Function(GdroidFieldsFragmentVarsBuilder b) updates]) = _$GdroidFieldsFragmentVars; - static Serializer get serializer => - _$gdroidFieldsFragmentVarsSerializer; Map toJson() => (_i2.serializers.serializeWith( GdroidFieldsFragmentVars.serializer, this, @@ -99,4 +100,162 @@ abstract class GdroidFieldsFragmentVars GdroidFieldsFragmentVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GdroidFieldsFragmentVarsSerializer(); +} + +class GHeroWithInterfaceSubTypedFragmentsVarsSerializer + extends StructuredSerializer { + final String wireName = 'GHeroWithInterfaceSubTypedFragmentsVars'; + + final Iterable types = const [ + GHeroWithInterfaceSubTypedFragmentsVars, + _$GHeroWithInterfaceSubTypedFragmentsVars + ]; + + Iterable serialize( + Serializers serializers, + GHeroWithInterfaceSubTypedFragmentsVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('episode'); + result.add(serializers.serialize(object.episode, + specifiedType: const FullType(_i1.GEpisode))); + return result; + } + + GHeroWithInterfaceSubTypedFragmentsVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GHeroWithInterfaceSubTypedFragmentsVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'episode': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; + builder.episode = fieldValue; + break; + } + } + return builder.build(); + } +} + +class GheroFieldsFragmentVarsSerializer + extends StructuredSerializer { + final String wireName = 'GheroFieldsFragmentVars'; + + final Iterable types = const [ + GheroFieldsFragmentVars, + _$GheroFieldsFragmentVars + ]; + + Iterable serialize( + Serializers serializers, + GheroFieldsFragmentVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + return result; + } + + GheroFieldsFragmentVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GheroFieldsFragmentVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + + } + } + return builder.build(); + } +} + +class GhumanFieldsFragmentVarsSerializer + extends StructuredSerializer { + final String wireName = 'GhumanFieldsFragmentVars'; + + final Iterable types = const [ + GhumanFieldsFragmentVars, + _$GhumanFieldsFragmentVars + ]; + + Iterable serialize( + Serializers serializers, + GhumanFieldsFragmentVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + return result; + } + + GhumanFieldsFragmentVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GhumanFieldsFragmentVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + + } + } + return builder.build(); + } +} + +class GdroidFieldsFragmentVarsSerializer + extends StructuredSerializer { + final String wireName = 'GdroidFieldsFragmentVars'; + + final Iterable types = const [ + GdroidFieldsFragmentVars, + _$GdroidFieldsFragmentVars + ]; + + Iterable serialize( + Serializers serializers, + GdroidFieldsFragmentVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + return result; + } + + GdroidFieldsFragmentVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GdroidFieldsFragmentVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + + } + } + return builder.build(); + } } diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.g.dart index 039e22cd..0689f5b4 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.g.dart @@ -6,137 +6,6 @@ part of 'hero_with_interface_subtyped_fragments.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** -Serializer - _$gHeroWithInterfaceSubTypedFragmentsVarsSerializer = - new _$GHeroWithInterfaceSubTypedFragmentsVarsSerializer(); -Serializer _$gheroFieldsFragmentVarsSerializer = - new _$GheroFieldsFragmentVarsSerializer(); -Serializer _$ghumanFieldsFragmentVarsSerializer = - new _$GhumanFieldsFragmentVarsSerializer(); -Serializer _$gdroidFieldsFragmentVarsSerializer = - new _$GdroidFieldsFragmentVarsSerializer(); - -class _$GHeroWithInterfaceSubTypedFragmentsVarsSerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - GHeroWithInterfaceSubTypedFragmentsVars, - _$GHeroWithInterfaceSubTypedFragmentsVars - ]; - @override - final String wireName = 'GHeroWithInterfaceSubTypedFragmentsVars'; - - @override - Iterable serialize( - Serializers serializers, GHeroWithInterfaceSubTypedFragmentsVars object, - {FullType specifiedType = FullType.unspecified}) { - final result = [ - 'episode', - serializers.serialize(object.episode, - specifiedType: const FullType(_i1.GEpisode)), - ]; - - return result; - } - - @override - GHeroWithInterfaceSubTypedFragmentsVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = new GHeroWithInterfaceSubTypedFragmentsVarsBuilder(); - - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current! as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'episode': - result.episode = serializers.deserialize(value, - specifiedType: const FullType(_i1.GEpisode))! as _i1.GEpisode; - break; - } - } - - return result.build(); - } -} - -class _$GheroFieldsFragmentVarsSerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - GheroFieldsFragmentVars, - _$GheroFieldsFragmentVars - ]; - @override - final String wireName = 'GheroFieldsFragmentVars'; - - @override - Iterable serialize( - Serializers serializers, GheroFieldsFragmentVars object, - {FullType specifiedType = FullType.unspecified}) { - return []; - } - - @override - GheroFieldsFragmentVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - return new GheroFieldsFragmentVarsBuilder().build(); - } -} - -class _$GhumanFieldsFragmentVarsSerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - GhumanFieldsFragmentVars, - _$GhumanFieldsFragmentVars - ]; - @override - final String wireName = 'GhumanFieldsFragmentVars'; - - @override - Iterable serialize( - Serializers serializers, GhumanFieldsFragmentVars object, - {FullType specifiedType = FullType.unspecified}) { - return []; - } - - @override - GhumanFieldsFragmentVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - return new GhumanFieldsFragmentVarsBuilder().build(); - } -} - -class _$GdroidFieldsFragmentVarsSerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - GdroidFieldsFragmentVars, - _$GdroidFieldsFragmentVars - ]; - @override - final String wireName = 'GdroidFieldsFragmentVars'; - - @override - Iterable serialize( - Serializers serializers, GdroidFieldsFragmentVars object, - {FullType specifiedType = FullType.unspecified}) { - return []; - } - - @override - GdroidFieldsFragmentVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - return new GdroidFieldsFragmentVarsBuilder().build(); - } -} - class _$GHeroWithInterfaceSubTypedFragmentsVars extends GHeroWithInterfaceSubTypedFragmentsVars { @override @@ -173,7 +42,10 @@ class _$GHeroWithInterfaceSubTypedFragmentsVars @override int get hashCode { - return $jf($jc(0, episode.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, episode.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -414,4 +286,4 @@ class GdroidFieldsFragmentVarsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/graphql/__generated__/schema.ast.gql.dart b/codegen/end_to_end_test/lib/graphql/__generated__/schema.ast.gql.dart index 118f4e7a..6fe4a9a0 100644 --- a/codegen/end_to_end_test/lib/graphql/__generated__/schema.ast.gql.dart +++ b/codegen/end_to_end_test/lib/graphql/__generated__/schema.ast.gql.dart @@ -226,7 +226,26 @@ const Mutation = _i1.ObjectTypeDefinitionNode( name: _i1.NameNode(value: 'Review'), isNonNull: false, ), - ) + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'createCustomField'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'input'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'CustomFieldInput'), + isNonNull: true, + ), + defaultValue: null, + ) + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'CustomField'), + isNonNull: false, + ), + ), ], ); const Subscription = _i1.ObjectTypeDefinitionNode( @@ -815,6 +834,30 @@ const ReviewInput = _i1.InputObjectTypeDefinitionNode( ), ], ); +const CustomFieldInput = _i1.InputObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'CustomFieldInput'), + directives: [], + fields: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'id'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'customField'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'CustomField'), + isNonNull: false, + ), + defaultValue: null, + ), + ], +); const ColorInput = _i1.InputObjectTypeDefinitionNode( name: _i1.NameNode(value: 'ColorInput'), directives: [], @@ -953,6 +996,7 @@ const document = _i1.DocumentNode(definitions: [ PageInfo, Review, ReviewInput, + CustomFieldInput, ColorInput, Starship, SearchResult, diff --git a/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.dart b/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.dart index a84cdbf5..db2526ce 100644 --- a/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.dart +++ b/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.dart @@ -5,10 +5,12 @@ import 'package:built_collection/built_collection.dart'; import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test/custom_field.dart' as _i2; import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' - as _i1; + as _i3; import 'package:gql_code_builder/src/serializers/default_scalar_serializer.dart' - as _i2; + as _i4; +import 'package:gql_exec/value.dart' as _i1; part 'schema.schema.gql.g.dart'; @@ -50,19 +52,171 @@ abstract class GReviewInput _$GReviewInput; int get stars; - String? get commentary; - GColorInput? get favorite_color; - BuiltList? get seenOn; - static Serializer get serializer => _$gReviewInputSerializer; - Map toJson() => (_i1.serializers.serializeWith( + _i1.Value? get commentary; + _i1.Value? get favorite_color; + _i1.Value>? get seenOn; + Map toJson() => (_i3.serializers.serializeWith( GReviewInput.serializer, this, ) as Map); static GReviewInput? fromJson(Map json) => - _i1.serializers.deserializeWith( + _i3.serializers.deserializeWith( GReviewInput.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => GReviewInputSerializer(); +} + +class GReviewInputSerializer extends StructuredSerializer { + final String wireName = 'GReviewInput'; + + final Iterable types = const [GReviewInput, _$GReviewInput]; + + Iterable serialize( + Serializers serializers, + GReviewInput object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('stars'); + result.add(serializers.serialize(object.stars, + specifiedType: const FullType(int))); + final _$commentaryvalue = object.commentary; + if (_$commentaryvalue != null) { + result.add('commentary'); + result.add(serializers.serialize(_$commentaryvalue!.value, + specifiedType: const FullType(String))); + } + final _$favorite_colorvalue = object.favorite_color; + if (_$favorite_colorvalue != null) { + result.add('favorite_color'); + result.add(serializers.serialize(_$favorite_colorvalue!.value, + specifiedType: const FullType(GColorInput))); + } + final _$seenOnvalue = object.seenOn; + if (_$seenOnvalue != null) { + result.add('seenOn'); + result.add(serializers.serialize(_$seenOnvalue!.value, + specifiedType: const FullType(BuiltList, [FullType(DateTime)]))); + } + return result; + } + + GReviewInput deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GReviewInputBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'stars': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + builder.stars = fieldValue; + break; + case 'commentary': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + builder.commentary = _i1.Value(fieldValue); + break; + case 'favorite_color': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(GColorInput)) as GColorInput; + builder.favorite_color = _i1.Value(fieldValue); + break; + case 'seenOn': + var fieldValue = serializers.deserialize(value, + specifiedType: + const FullType(BuiltList, [FullType(DateTime)])) + as BuiltList; + builder.seenOn = _i1.Value(fieldValue); + break; + } + } + return builder.build(); + } +} + +abstract class GCustomFieldInput + implements Built { + GCustomFieldInput._(); + + factory GCustomFieldInput([Function(GCustomFieldInputBuilder b) updates]) = + _$GCustomFieldInput; + + String get id; + _i1.Value<_i2.CustomField>? get customField; + Map toJson() => (_i3.serializers.serializeWith( + GCustomFieldInput.serializer, + this, + ) as Map); + static GCustomFieldInput? fromJson(Map json) => + _i3.serializers.deserializeWith( + GCustomFieldInput.serializer, + json, + ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GCustomFieldInputSerializer(); +} + +class GCustomFieldInputSerializer + extends StructuredSerializer { + final String wireName = 'GCustomFieldInput'; + + final Iterable types = const [GCustomFieldInput, _$GCustomFieldInput]; + + Iterable serialize( + Serializers serializers, + GCustomFieldInput object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('id'); + result.add(serializers.serialize(object.id, + specifiedType: const FullType(String))); + final _$customFieldvalue = object.customField; + if (_$customFieldvalue != null) { + result.add('customField'); + result.add(serializers.serialize(_$customFieldvalue!.value, + specifiedType: const FullType(_i2.CustomField))); + } + return result; + } + + GCustomFieldInput deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GCustomFieldInputBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'id': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + builder.id = fieldValue; + break; + case 'customField': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i2.CustomField)) + as _i2.CustomField; + builder.customField = _i1.Value(fieldValue); + break; + } + } + return builder.build(); + } } abstract class GColorInput implements Built { @@ -73,16 +227,73 @@ abstract class GColorInput implements Built { int get red; int get green; int get blue; - static Serializer get serializer => _$gColorInputSerializer; - Map toJson() => (_i1.serializers.serializeWith( + Map toJson() => (_i3.serializers.serializeWith( GColorInput.serializer, this, ) as Map); static GColorInput? fromJson(Map json) => - _i1.serializers.deserializeWith( + _i3.serializers.deserializeWith( GColorInput.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => GColorInputSerializer(); +} + +class GColorInputSerializer extends StructuredSerializer { + final String wireName = 'GColorInput'; + + final Iterable types = const [GColorInput, _$GColorInput]; + + Iterable serialize( + Serializers serializers, + GColorInput object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('red'); + result.add( + serializers.serialize(object.red, specifiedType: const FullType(int))); + result.add('green'); + result.add(serializers.serialize(object.green, + specifiedType: const FullType(int))); + result.add('blue'); + result.add( + serializers.serialize(object.blue, specifiedType: const FullType(int))); + return result; + } + + GColorInput deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GColorInputBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'red': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + builder.red = fieldValue; + break; + case 'green': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + builder.green = fieldValue; + break; + case 'blue': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + builder.blue = fieldValue; + break; + } + } + return builder.build(); + } } abstract class GISODate implements Built { @@ -94,7 +305,7 @@ abstract class GISODate implements Built { String get value; @BuiltValueSerializer(custom: true) static Serializer get serializer => - _i2.DefaultScalarSerializer( + _i4.DefaultScalarSerializer( (Object serialized) => GISODate((serialized as String?))); } diff --git a/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.g.dart b/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.g.dart index 9a393483..c906df68 100644 --- a/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.g.dart +++ b/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.g.dart @@ -52,9 +52,6 @@ final BuiltSet _$gLengthUnitValues = Serializer _$gEpisodeSerializer = new _$GEpisodeSerializer(); Serializer _$gLengthUnitSerializer = new _$GLengthUnitSerializer(); -Serializer _$gReviewInputSerializer = - new _$GReviewInputSerializer(); -Serializer _$gColorInputSerializer = new _$GColorInputSerializer(); class _$GEpisodeSerializer implements PrimitiveSerializer { @override @@ -98,142 +95,15 @@ class _$GLengthUnitSerializer implements PrimitiveSerializer { _fromWire[serialized] ?? (serialized is String ? serialized : '')); } -class _$GReviewInputSerializer implements StructuredSerializer { - @override - final Iterable types = const [GReviewInput, _$GReviewInput]; - @override - final String wireName = 'GReviewInput'; - - @override - Iterable serialize(Serializers serializers, GReviewInput object, - {FullType specifiedType = FullType.unspecified}) { - final result = [ - 'stars', - serializers.serialize(object.stars, specifiedType: const FullType(int)), - ]; - Object? value; - value = object.commentary; - if (value != null) { - result - ..add('commentary') - ..add(serializers.serialize(value, - specifiedType: const FullType(String))); - } - value = object.favorite_color; - if (value != null) { - result - ..add('favorite_color') - ..add(serializers.serialize(value, - specifiedType: const FullType(GColorInput))); - } - value = object.seenOn; - if (value != null) { - result - ..add('seenOn') - ..add(serializers.serialize(value, - specifiedType: const FullType( - BuiltList, const [const FullType.nullable(DateTime)]))); - } - return result; - } - - @override - GReviewInput deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = new GReviewInputBuilder(); - - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current! as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'stars': - result.stars = serializers.deserialize(value, - specifiedType: const FullType(int))! as int; - break; - case 'commentary': - result.commentary = serializers.deserialize(value, - specifiedType: const FullType(String)) as String?; - break; - case 'favorite_color': - result.favorite_color.replace(serializers.deserialize(value, - specifiedType: const FullType(GColorInput))! as GColorInput); - break; - case 'seenOn': - result.seenOn.replace(serializers.deserialize(value, - specifiedType: const FullType( - BuiltList, const [const FullType.nullable(DateTime)]))! - as BuiltList); - break; - } - } - - return result.build(); - } -} - -class _$GColorInputSerializer implements StructuredSerializer { - @override - final Iterable types = const [GColorInput, _$GColorInput]; - @override - final String wireName = 'GColorInput'; - - @override - Iterable serialize(Serializers serializers, GColorInput object, - {FullType specifiedType = FullType.unspecified}) { - final result = [ - 'red', - serializers.serialize(object.red, specifiedType: const FullType(int)), - 'green', - serializers.serialize(object.green, specifiedType: const FullType(int)), - 'blue', - serializers.serialize(object.blue, specifiedType: const FullType(int)), - ]; - - return result; - } - - @override - GColorInput deserialize(Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = new GColorInputBuilder(); - - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current! as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'red': - result.red = serializers.deserialize(value, - specifiedType: const FullType(int))! as int; - break; - case 'green': - result.green = serializers.deserialize(value, - specifiedType: const FullType(int))! as int; - break; - case 'blue': - result.blue = serializers.deserialize(value, - specifiedType: const FullType(int))! as int; - break; - } - } - - return result.build(); - } -} - class _$GReviewInput extends GReviewInput { @override final int stars; @override - final String? commentary; + final _i1.Value? commentary; @override - final GColorInput? favorite_color; + final _i1.Value? favorite_color; @override - final BuiltList? seenOn; + final _i1.Value>? seenOn; factory _$GReviewInput([void Function(GReviewInputBuilder)? updates]) => (new GReviewInputBuilder()..update(updates))._build(); @@ -263,10 +133,13 @@ class _$GReviewInput extends GReviewInput { @override int get hashCode { - return $jf($jc( - $jc($jc($jc(0, stars.hashCode), commentary.hashCode), - favorite_color.hashCode), - seenOn.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, stars.hashCode); + _$hash = $jc(_$hash, commentary.hashCode); + _$hash = $jc(_$hash, favorite_color.hashCode); + _$hash = $jc(_$hash, seenOn.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -288,20 +161,20 @@ class GReviewInputBuilder int? get stars => _$this._stars; set stars(int? stars) => _$this._stars = stars; - String? _commentary; - String? get commentary => _$this._commentary; - set commentary(String? commentary) => _$this._commentary = commentary; + _i1.Value? _commentary; + _i1.Value? get commentary => _$this._commentary; + set commentary(_i1.Value? commentary) => + _$this._commentary = commentary; - GColorInputBuilder? _favorite_color; - GColorInputBuilder get favorite_color => - _$this._favorite_color ??= new GColorInputBuilder(); - set favorite_color(GColorInputBuilder? favorite_color) => + _i1.Value? _favorite_color; + _i1.Value? get favorite_color => _$this._favorite_color; + set favorite_color(_i1.Value? favorite_color) => _$this._favorite_color = favorite_color; - ListBuilder? _seenOn; - ListBuilder get seenOn => - _$this._seenOn ??= new ListBuilder(); - set seenOn(ListBuilder? seenOn) => _$this._seenOn = seenOn; + _i1.Value>? _seenOn; + _i1.Value>? get seenOn => _$this._seenOn; + set seenOn(_i1.Value>? seenOn) => + _$this._seenOn = seenOn; GReviewInputBuilder(); @@ -310,8 +183,8 @@ class GReviewInputBuilder if ($v != null) { _stars = $v.stars; _commentary = $v.commentary; - _favorite_color = $v.favorite_color?.toBuilder(); - _seenOn = $v.seenOn?.toBuilder(); + _favorite_color = $v.favorite_color; + _seenOn = $v.seenOn; _$v = null; } return this; @@ -332,28 +205,111 @@ class GReviewInputBuilder GReviewInput build() => _build(); _$GReviewInput _build() { - _$GReviewInput _$result; - try { - _$result = _$v ?? - new _$GReviewInput._( - stars: BuiltValueNullFieldError.checkNotNull( - stars, r'GReviewInput', 'stars'), - commentary: commentary, - favorite_color: _favorite_color?.build(), - seenOn: _seenOn?.build()); - } catch (_) { - late String _$failedField; - try { - _$failedField = 'favorite_color'; - _favorite_color?.build(); - _$failedField = 'seenOn'; - _seenOn?.build(); - } catch (e) { - throw new BuiltValueNestedFieldError( - r'GReviewInput', _$failedField, e.toString()); - } - rethrow; + final _$result = _$v ?? + new _$GReviewInput._( + stars: BuiltValueNullFieldError.checkNotNull( + stars, r'GReviewInput', 'stars'), + commentary: commentary, + favorite_color: favorite_color, + seenOn: seenOn); + replace(_$result); + return _$result; + } +} + +class _$GCustomFieldInput extends GCustomFieldInput { + @override + final String id; + @override + final _i1.Value<_i2.CustomField>? customField; + + factory _$GCustomFieldInput( + [void Function(GCustomFieldInputBuilder)? updates]) => + (new GCustomFieldInputBuilder()..update(updates))._build(); + + _$GCustomFieldInput._({required this.id, this.customField}) : super._() { + BuiltValueNullFieldError.checkNotNull(id, r'GCustomFieldInput', 'id'); + } + + @override + GCustomFieldInput rebuild(void Function(GCustomFieldInputBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GCustomFieldInputBuilder toBuilder() => + new GCustomFieldInputBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GCustomFieldInput && + id == other.id && + customField == other.customField; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, customField.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GCustomFieldInput') + ..add('id', id) + ..add('customField', customField)) + .toString(); + } +} + +class GCustomFieldInputBuilder + implements Builder { + _$GCustomFieldInput? _$v; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + _i1.Value<_i2.CustomField>? _customField; + _i1.Value<_i2.CustomField>? get customField => _$this._customField; + set customField(_i1.Value<_i2.CustomField>? customField) => + _$this._customField = customField; + + GCustomFieldInputBuilder(); + + GCustomFieldInputBuilder get _$this { + final $v = _$v; + if ($v != null) { + _id = $v.id; + _customField = $v.customField; + _$v = null; } + return this; + } + + @override + void replace(GCustomFieldInput other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GCustomFieldInput; + } + + @override + void update(void Function(GCustomFieldInputBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GCustomFieldInput build() => _build(); + + _$GCustomFieldInput _build() { + final _$result = _$v ?? + new _$GCustomFieldInput._( + id: BuiltValueNullFieldError.checkNotNull( + id, r'GCustomFieldInput', 'id'), + customField: customField); replace(_$result); return _$result; } @@ -395,7 +351,12 @@ class _$GColorInput extends GColorInput { @override int get hashCode { - return $jf($jc($jc($jc(0, red.hashCode), green.hashCode), blue.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, red.hashCode); + _$hash = $jc(_$hash, green.hashCode); + _$hash = $jc(_$hash, blue.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -490,7 +451,10 @@ class _$GISODate extends GISODate { @override int get hashCode { - return $jf($jc(0, value.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, value.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -542,4 +506,4 @@ class GISODateBuilder implements Builder { } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/graphql/__generated__/serializers.gql.dart b/codegen/end_to_end_test/lib/graphql/__generated__/serializers.gql.dart index 28626ae9..75eee6b9 100644 --- a/codegen/end_to_end_test/lib/graphql/__generated__/serializers.gql.dart +++ b/codegen/end_to_end_test/lib/graphql/__generated__/serializers.gql.dart @@ -57,7 +57,13 @@ import 'package:end_to_end_test/fragments/__generated__/hero_with_interface_subt GheroFieldsFragmentVars, GhumanFieldsFragmentVars; import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart' - show GColorInput, GEpisode, GISODate, GLengthUnit, GReviewInput; + show + GColorInput, + GCustomFieldInput, + GEpisode, + GISODate, + GLengthUnit, + GReviewInput; import 'package:end_to_end_test/interfaces/__generated__/hero_for_episode.data.gql.dart' show GHeroForEpisodeData_hero, @@ -83,6 +89,12 @@ import 'package:end_to_end_test/scalars/__generated__/review_with_date.req.gql.d show GReviewWithDate; import 'package:end_to_end_test/scalars/__generated__/review_with_date.var.gql.dart' show GReviewWithDateVars; +import 'package:end_to_end_test/variables/__generated__/create_custom_field.data.gql.dart' + show GCreateCustomFieldData; +import 'package:end_to_end_test/variables/__generated__/create_custom_field.req.gql.dart' + show GCreateCustomField; +import 'package:end_to_end_test/variables/__generated__/create_custom_field.var.gql.dart' + show GCreateCustomFieldVars; import 'package:end_to_end_test/variables/__generated__/create_review.data.gql.dart' show GCreateReviewData, GCreateReviewData_createReview; import 'package:end_to_end_test/variables/__generated__/create_review.req.gql.dart' @@ -116,10 +128,14 @@ final SerializersBuilder _serializersBuilder = _$serializers.toBuilder() GAliasedHeroData_jediHero, GAliasedHeroVars, GColorInput, + GCreateCustomField, + GCreateCustomFieldData, + GCreateCustomFieldVars, GCreateReview, GCreateReviewData, GCreateReviewData_createReview, GCreateReviewVars, + GCustomFieldInput, GDroidFragmentData, GDroidFragmentVars, GEpisode, diff --git a/codegen/end_to_end_test/lib/graphql/__generated__/serializers.gql.g.dart b/codegen/end_to_end_test/lib/graphql/__generated__/serializers.gql.g.dart index 4a6a2114..fe1d753a 100644 --- a/codegen/end_to_end_test/lib/graphql/__generated__/serializers.gql.g.dart +++ b/codegen/end_to_end_test/lib/graphql/__generated__/serializers.gql.g.dart @@ -13,10 +13,14 @@ Serializers _$serializers = (new Serializers().toBuilder() ..add(GAliasedHeroData_jediHero.serializer) ..add(GAliasedHeroVars.serializer) ..add(GColorInput.serializer) + ..add(GCreateCustomField.serializer) + ..add(GCreateCustomFieldData.serializer) + ..add(GCreateCustomFieldVars.serializer) ..add(GCreateReview.serializer) ..add(GCreateReviewData.serializer) ..add(GCreateReviewData_createReview.serializer) ..add(GCreateReviewVars.serializer) + ..add(GCustomFieldInput.serializer) ..add(GDroidFragmentData.serializer) ..add(GDroidFragmentVars.serializer) ..add(GEpisode.serializer) @@ -80,9 +84,6 @@ Serializers _$serializers = (new Serializers().toBuilder() ..addBuilderFactory( const FullType(BuiltList, const [const FullType(CustomField)]), () => new ListBuilder()) - ..addBuilderFactory( - const FullType(BuiltList, const [const FullType.nullable(DateTime)]), - () => new ListBuilder()) ..addBuilderFactory( const FullType(BuiltList, const [const FullType.nullable(GEpisode)]), () => new ListBuilder()) @@ -125,4 +126,4 @@ Serializers _$serializers = (new Serializers().toBuilder() () => new ListBuilder())) .build(); -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/graphql/schema.graphql b/codegen/end_to_end_test/lib/graphql/schema.graphql index c95faa8f..bcd72c20 100644 --- a/codegen/end_to_end_test/lib/graphql/schema.graphql +++ b/codegen/end_to_end_test/lib/graphql/schema.graphql @@ -23,6 +23,7 @@ type Query { # The mutation type, represents all updates we can make to our data type Mutation { createReview(episode: Episode, review: ReviewInput!, createdAt: Date): Review + createCustomField(input: CustomFieldInput!): CustomField } # The subscription type, represents all subscriptions we can make to our data @@ -157,6 +158,11 @@ input ReviewInput { seenOn: [Date] } +input CustomFieldInput { + id: ID! + customField: CustomField +} + # The input object sent when passing in a color input ColorInput { red: Int! diff --git a/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.data.gql.g.dart b/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.data.gql.g.dart index 3fa28c16..ee58bc38 100644 --- a/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.data.gql.g.dart +++ b/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.data.gql.g.dart @@ -419,7 +419,11 @@ class _$GHeroForEpisodeData extends GHeroForEpisodeData { @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), hero.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, hero.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -523,8 +527,12 @@ class _$GHeroForEpisodeData_hero__base extends GHeroForEpisodeData_hero__base { @override int get hashCode { - return $jf($jc( - $jc($jc(0, G__typename.hashCode), name.hashCode), friends.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, friends.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -655,7 +663,11 @@ class _$GHeroForEpisodeData_hero__base_friends @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), name.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -772,9 +784,13 @@ class _$GHeroForEpisodeData_hero__asDroid @override int get hashCode { - return $jf($jc( - $jc($jc($jc(0, G__typename.hashCode), name.hashCode), friends.hashCode), - primaryFunction.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, friends.hashCode); + _$hash = $jc(_$hash, primaryFunction.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -915,7 +931,11 @@ class _$GHeroForEpisodeData_hero__asDroid_friends @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), name.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1019,7 +1039,11 @@ class _$GDroidFragmentData extends GDroidFragmentData { @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), primaryFunction.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, primaryFunction.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -1083,4 +1107,4 @@ class GDroidFragmentDataBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.req.gql.g.dart b/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.req.gql.g.dart index 62c43d0e..fbeddc86 100644 --- a/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.req.gql.g.dart +++ b/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.req.gql.g.dart @@ -93,7 +93,11 @@ class _$GHeroForEpisode extends GHeroForEpisode { @override int get hashCode { - return $jf($jc($jc(0, vars.hashCode), operation.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -170,4 +174,4 @@ class GHeroForEpisodeBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.dart b/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.dart index 940f6b8c..28c7d976 100644 --- a/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.dart +++ b/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.dart @@ -19,8 +19,6 @@ abstract class GHeroForEpisodeVars [Function(GHeroForEpisodeVarsBuilder b) updates]) = _$GHeroForEpisodeVars; _i1.GEpisode get ep; - static Serializer get serializer => - _$gHeroForEpisodeVarsSerializer; Map toJson() => (_i2.serializers.serializeWith( GHeroForEpisodeVars.serializer, this, @@ -30,6 +28,9 @@ abstract class GHeroForEpisodeVars GHeroForEpisodeVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GHeroForEpisodeVarsSerializer(); } abstract class GDroidFragmentVars @@ -39,8 +40,6 @@ abstract class GDroidFragmentVars factory GDroidFragmentVars([Function(GDroidFragmentVarsBuilder b) updates]) = _$GDroidFragmentVars; - static Serializer get serializer => - _$gDroidFragmentVarsSerializer; Map toJson() => (_i2.serializers.serializeWith( GDroidFragmentVars.serializer, this, @@ -50,4 +49,85 @@ abstract class GDroidFragmentVars GDroidFragmentVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GDroidFragmentVarsSerializer(); +} + +class GHeroForEpisodeVarsSerializer + extends StructuredSerializer { + final String wireName = 'GHeroForEpisodeVars'; + + final Iterable types = const [ + GHeroForEpisodeVars, + _$GHeroForEpisodeVars + ]; + + Iterable serialize( + Serializers serializers, + GHeroForEpisodeVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('ep'); + result.add(serializers.serialize(object.ep, + specifiedType: const FullType(_i1.GEpisode))); + return result; + } + + GHeroForEpisodeVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GHeroForEpisodeVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'ep': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; + builder.ep = fieldValue; + break; + } + } + return builder.build(); + } +} + +class GDroidFragmentVarsSerializer + extends StructuredSerializer { + final String wireName = 'GDroidFragmentVars'; + + final Iterable types = const [GDroidFragmentVars, _$GDroidFragmentVars]; + + Iterable serialize( + Serializers serializers, + GDroidFragmentVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + return result; + } + + GDroidFragmentVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GDroidFragmentVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + + } + } + return builder.build(); + } } diff --git a/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.g.dart b/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.g.dart index 89ab68f7..5ff1690c 100644 --- a/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.g.dart @@ -6,79 +6,6 @@ part of 'hero_for_episode.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** -Serializer _$gHeroForEpisodeVarsSerializer = - new _$GHeroForEpisodeVarsSerializer(); -Serializer _$gDroidFragmentVarsSerializer = - new _$GDroidFragmentVarsSerializer(); - -class _$GHeroForEpisodeVarsSerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - GHeroForEpisodeVars, - _$GHeroForEpisodeVars - ]; - @override - final String wireName = 'GHeroForEpisodeVars'; - - @override - Iterable serialize( - Serializers serializers, GHeroForEpisodeVars object, - {FullType specifiedType = FullType.unspecified}) { - final result = [ - 'ep', - serializers.serialize(object.ep, - specifiedType: const FullType(_i1.GEpisode)), - ]; - - return result; - } - - @override - GHeroForEpisodeVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = new GHeroForEpisodeVarsBuilder(); - - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current! as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'ep': - result.ep = serializers.deserialize(value, - specifiedType: const FullType(_i1.GEpisode))! as _i1.GEpisode; - break; - } - } - - return result.build(); - } -} - -class _$GDroidFragmentVarsSerializer - implements StructuredSerializer { - @override - final Iterable types = const [GDroidFragmentVars, _$GDroidFragmentVars]; - @override - final String wireName = 'GDroidFragmentVars'; - - @override - Iterable serialize( - Serializers serializers, GDroidFragmentVars object, - {FullType specifiedType = FullType.unspecified}) { - return []; - } - - @override - GDroidFragmentVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - return new GDroidFragmentVarsBuilder().build(); - } -} - class _$GHeroForEpisodeVars extends GHeroForEpisodeVars { @override final _i1.GEpisode ep; @@ -108,7 +35,10 @@ class _$GHeroForEpisodeVars extends GHeroForEpisodeVars { @override int get hashCode { - return $jf($jc(0, ep.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, ep.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -221,4 +151,4 @@ class GDroidFragmentVarsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.data.gql.g.dart b/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.data.gql.g.dart index a98b4caf..849ff651 100644 --- a/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.data.gql.g.dart +++ b/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.data.gql.g.dart @@ -155,7 +155,11 @@ class _$GHeroNoVarsData extends GHeroNoVarsData { @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), hero.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, hero.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -274,8 +278,12 @@ class _$GHeroNoVarsData_hero extends GHeroNoVarsData_hero { @override int get hashCode { - return $jf( - $jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -347,4 +355,4 @@ class GHeroNoVarsData_heroBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.req.gql.g.dart b/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.req.gql.g.dart index ac4dc32c..d42882c5 100644 --- a/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.req.gql.g.dart +++ b/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.req.gql.g.dart @@ -88,7 +88,11 @@ class _$GHeroNoVars extends GHeroNoVars { @override int get hashCode { - return $jf($jc($jc(0, vars.hashCode), operation.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -164,4 +168,4 @@ class GHeroNoVarsBuilder implements Builder { } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.dart b/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.dart index 475a3655..ad0bc3cd 100644 --- a/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.dart +++ b/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.dart @@ -16,8 +16,6 @@ abstract class GHeroNoVarsVars factory GHeroNoVarsVars([Function(GHeroNoVarsVarsBuilder b) updates]) = _$GHeroNoVarsVars; - static Serializer get serializer => - _$gHeroNoVarsVarsSerializer; Map toJson() => (_i1.serializers.serializeWith( GHeroNoVarsVars.serializer, this, @@ -27,4 +25,40 @@ abstract class GHeroNoVarsVars GHeroNoVarsVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GHeroNoVarsVarsSerializer(); +} + +class GHeroNoVarsVarsSerializer extends StructuredSerializer { + final String wireName = 'GHeroNoVarsVars'; + + final Iterable types = const [GHeroNoVarsVars, _$GHeroNoVarsVars]; + + Iterable serialize( + Serializers serializers, + GHeroNoVarsVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + return result; + } + + GHeroNoVarsVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GHeroNoVarsVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + + } + } + return builder.build(); + } } diff --git a/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.g.dart b/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.g.dart index 4b0f9bbc..f5ef2947 100644 --- a/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.g.dart @@ -6,30 +6,6 @@ part of 'hero_no_vars.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** -Serializer _$gHeroNoVarsVarsSerializer = - new _$GHeroNoVarsVarsSerializer(); - -class _$GHeroNoVarsVarsSerializer - implements StructuredSerializer { - @override - final Iterable types = const [GHeroNoVarsVars, _$GHeroNoVarsVars]; - @override - final String wireName = 'GHeroNoVarsVars'; - - @override - Iterable serialize(Serializers serializers, GHeroNoVarsVars object, - {FullType specifiedType = FullType.unspecified}) { - return []; - } - - @override - GHeroNoVarsVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - return new GHeroNoVarsVarsBuilder().build(); - } -} - class _$GHeroNoVarsVars extends GHeroNoVarsVars { factory _$GHeroNoVarsVars([void Function(GHeroNoVarsVarsBuilder)? updates]) => (new GHeroNoVarsVarsBuilder()..update(updates))._build(); @@ -88,4 +64,4 @@ class GHeroNoVarsVarsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.data.gql.g.dart b/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.data.gql.g.dart index 1d688b3b..dd131b05 100644 --- a/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.data.gql.g.dart +++ b/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.data.gql.g.dart @@ -211,7 +211,11 @@ class _$GReviewWithDateData extends GReviewWithDateData { @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), createReview.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, createReview.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -353,16 +357,16 @@ class _$GReviewWithDateData_createReview @override int get hashCode { - return $jf($jc( - $jc( - $jc( - $jc( - $jc($jc($jc(0, G__typename.hashCode), episode.hashCode), - stars.hashCode), - commentary.hashCode), - createdAt.hashCode), - seenOn.hashCode), - custom.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, episode.hashCode); + _$hash = $jc(_$hash, stars.hashCode); + _$hash = $jc(_$hash, commentary.hashCode); + _$hash = $jc(_$hash, createdAt.hashCode); + _$hash = $jc(_$hash, seenOn.hashCode); + _$hash = $jc(_$hash, custom.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -480,4 +484,4 @@ class GReviewWithDateData_createReviewBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.req.gql.g.dart b/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.req.gql.g.dart index 8243b548..91d79828 100644 --- a/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.req.gql.g.dart +++ b/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.req.gql.g.dart @@ -93,7 +93,11 @@ class _$GReviewWithDate extends GReviewWithDate { @override int get hashCode { - return $jf($jc($jc(0, vars.hashCode), operation.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -170,4 +174,4 @@ class GReviewWithDateBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.dart b/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.dart index d4761993..59fecc54 100644 --- a/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.dart +++ b/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.dart @@ -7,7 +7,8 @@ import 'package:built_value/serializer.dart'; import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart' as _i1; import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' - as _i2; + as _i3; +import 'package:gql_exec/value.dart' as _i2; part 'review_with_date.var.gql.g.dart'; @@ -18,18 +19,86 @@ abstract class GReviewWithDateVars factory GReviewWithDateVars( [Function(GReviewWithDateVarsBuilder b) updates]) = _$GReviewWithDateVars; - _i1.GEpisode? get episode; + _i2.Value<_i1.GEpisode>? get episode; _i1.GReviewInput get review; - DateTime? get createdAt; - static Serializer get serializer => - _$gReviewWithDateVarsSerializer; - Map toJson() => (_i2.serializers.serializeWith( + _i2.Value? get createdAt; + Map toJson() => (_i3.serializers.serializeWith( GReviewWithDateVars.serializer, this, ) as Map); static GReviewWithDateVars? fromJson(Map json) => - _i2.serializers.deserializeWith( + _i3.serializers.deserializeWith( GReviewWithDateVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GReviewWithDateVarsSerializer(); +} + +class GReviewWithDateVarsSerializer + extends StructuredSerializer { + final String wireName = 'GReviewWithDateVars'; + + final Iterable types = const [ + GReviewWithDateVars, + _$GReviewWithDateVars + ]; + + Iterable serialize( + Serializers serializers, + GReviewWithDateVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + final _$episodevalue = object.episode; + if (_$episodevalue != null) { + result.add('episode'); + result.add(serializers.serialize(_$episodevalue!.value, + specifiedType: const FullType(_i1.GEpisode))); + } + result.add('review'); + result.add(serializers.serialize(object.review, + specifiedType: const FullType(_i1.GReviewInput))); + final _$createdAtvalue = object.createdAt; + if (_$createdAtvalue != null) { + result.add('createdAt'); + result.add(serializers.serialize(_$createdAtvalue!.value, + specifiedType: const FullType(DateTime))); + } + return result; + } + + GReviewWithDateVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GReviewWithDateVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'episode': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; + builder.episode = _i2.Value(fieldValue); + break; + case 'review': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i1.GReviewInput)) + as _i1.GReviewInput; + builder.review.replace(fieldValue); + break; + case 'createdAt': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(DateTime)) as DateTime; + builder.createdAt = _i2.Value(fieldValue); + break; + } + } + return builder.build(); + } } diff --git a/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.g.dart b/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.g.dart index b02235e2..a75571b1 100644 --- a/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.g.dart @@ -6,85 +6,13 @@ part of 'review_with_date.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** -Serializer _$gReviewWithDateVarsSerializer = - new _$GReviewWithDateVarsSerializer(); - -class _$GReviewWithDateVarsSerializer - implements StructuredSerializer { - @override - final Iterable types = const [ - GReviewWithDateVars, - _$GReviewWithDateVars - ]; - @override - final String wireName = 'GReviewWithDateVars'; - - @override - Iterable serialize( - Serializers serializers, GReviewWithDateVars object, - {FullType specifiedType = FullType.unspecified}) { - final result = [ - 'review', - serializers.serialize(object.review, - specifiedType: const FullType(_i1.GReviewInput)), - ]; - Object? value; - value = object.episode; - if (value != null) { - result - ..add('episode') - ..add(serializers.serialize(value, - specifiedType: const FullType(_i1.GEpisode))); - } - value = object.createdAt; - if (value != null) { - result - ..add('createdAt') - ..add(serializers.serialize(value, - specifiedType: const FullType(DateTime))); - } - return result; - } - - @override - GReviewWithDateVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = new GReviewWithDateVarsBuilder(); - - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current! as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'episode': - result.episode = serializers.deserialize(value, - specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode?; - break; - case 'review': - result.review.replace(serializers.deserialize(value, - specifiedType: const FullType(_i1.GReviewInput))! - as _i1.GReviewInput); - break; - case 'createdAt': - result.createdAt = serializers.deserialize(value, - specifiedType: const FullType(DateTime)) as DateTime?; - break; - } - } - - return result.build(); - } -} - class _$GReviewWithDateVars extends GReviewWithDateVars { @override - final _i1.GEpisode? episode; + final _i2.Value<_i1.GEpisode>? episode; @override final _i1.GReviewInput review; @override - final DateTime? createdAt; + final _i2.Value? createdAt; factory _$GReviewWithDateVars( [void Function(GReviewWithDateVarsBuilder)? updates]) => @@ -116,8 +44,12 @@ class _$GReviewWithDateVars extends GReviewWithDateVars { @override int get hashCode { - return $jf($jc( - $jc($jc(0, episode.hashCode), review.hashCode), createdAt.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, episode.hashCode); + _$hash = $jc(_$hash, review.hashCode); + _$hash = $jc(_$hash, createdAt.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -134,18 +66,19 @@ class GReviewWithDateVarsBuilder implements Builder { _$GReviewWithDateVars? _$v; - _i1.GEpisode? _episode; - _i1.GEpisode? get episode => _$this._episode; - set episode(_i1.GEpisode? episode) => _$this._episode = episode; + _i2.Value<_i1.GEpisode>? _episode; + _i2.Value<_i1.GEpisode>? get episode => _$this._episode; + set episode(_i2.Value<_i1.GEpisode>? episode) => _$this._episode = episode; _i1.GReviewInputBuilder? _review; _i1.GReviewInputBuilder get review => _$this._review ??= new _i1.GReviewInputBuilder(); set review(_i1.GReviewInputBuilder? review) => _$this._review = review; - DateTime? _createdAt; - DateTime? get createdAt => _$this._createdAt; - set createdAt(DateTime? createdAt) => _$this._createdAt = createdAt; + _i2.Value? _createdAt; + _i2.Value? get createdAt => _$this._createdAt; + set createdAt(_i2.Value? createdAt) => + _$this._createdAt = createdAt; GReviewWithDateVarsBuilder(); @@ -196,4 +129,4 @@ class GReviewWithDateVarsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.ast.gql.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.ast.gql.dart new file mode 100644 index 00000000..31da7675 --- /dev/null +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.ast.gql.dart @@ -0,0 +1,37 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const CreateCustomField = _i1.OperationDefinitionNode( + type: _i1.OperationType.mutation, + name: _i1.NameNode(value: 'CreateCustomField'), + variableDefinitions: [ + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'input')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'CustomFieldInput'), + isNonNull: true, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'createCustomField'), + alias: null, + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'input'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'input')), + ) + ], + directives: [], + selectionSet: null, + ) + ]), +); +const document = _i1.DocumentNode(definitions: [CreateCustomField]); diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.data.gql.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.data.gql.dart new file mode 100644 index 00000000..38b35f22 --- /dev/null +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.data.gql.dart @@ -0,0 +1,37 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test/custom_field.dart' as _i1; +import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' + as _i2; + +part 'create_custom_field.data.gql.g.dart'; + +abstract class GCreateCustomFieldData + implements Built { + GCreateCustomFieldData._(); + + factory GCreateCustomFieldData( + [Function(GCreateCustomFieldDataBuilder b) updates]) = + _$GCreateCustomFieldData; + + static void _initializeBuilder(GCreateCustomFieldDataBuilder b) => + b..G__typename = 'Mutation'; + @BuiltValueField(wireName: '__typename') + String get G__typename; + _i1.CustomField? get createCustomField; + static Serializer get serializer => + _$gCreateCustomFieldDataSerializer; + Map toJson() => (_i2.serializers.serializeWith( + GCreateCustomFieldData.serializer, + this, + ) as Map); + static GCreateCustomFieldData? fromJson(Map json) => + _i2.serializers.deserializeWith( + GCreateCustomFieldData.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.data.gql.g.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.data.gql.g.dart new file mode 100644 index 00000000..2b151a87 --- /dev/null +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.data.gql.g.dart @@ -0,0 +1,174 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'create_custom_field.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gCreateCustomFieldDataSerializer = + new _$GCreateCustomFieldDataSerializer(); + +class _$GCreateCustomFieldDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GCreateCustomFieldData, + _$GCreateCustomFieldData + ]; + @override + final String wireName = 'GCreateCustomFieldData'; + + @override + Iterable serialize( + Serializers serializers, GCreateCustomFieldData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.createCustomField; + if (value != null) { + result + ..add('createCustomField') + ..add(serializers.serialize(value, + specifiedType: const FullType(_i1.CustomField))); + } + return result; + } + + @override + GCreateCustomFieldData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GCreateCustomFieldDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'createCustomField': + result.createCustomField = serializers.deserialize(value, + specifiedType: const FullType(_i1.CustomField)) + as _i1.CustomField?; + break; + } + } + + return result.build(); + } +} + +class _$GCreateCustomFieldData extends GCreateCustomFieldData { + @override + final String G__typename; + @override + final _i1.CustomField? createCustomField; + + factory _$GCreateCustomFieldData( + [void Function(GCreateCustomFieldDataBuilder)? updates]) => + (new GCreateCustomFieldDataBuilder()..update(updates))._build(); + + _$GCreateCustomFieldData._( + {required this.G__typename, this.createCustomField}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GCreateCustomFieldData', 'G__typename'); + } + + @override + GCreateCustomFieldData rebuild( + void Function(GCreateCustomFieldDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GCreateCustomFieldDataBuilder toBuilder() => + new GCreateCustomFieldDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GCreateCustomFieldData && + G__typename == other.G__typename && + createCustomField == other.createCustomField; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, createCustomField.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GCreateCustomFieldData') + ..add('G__typename', G__typename) + ..add('createCustomField', createCustomField)) + .toString(); + } +} + +class GCreateCustomFieldDataBuilder + implements Builder { + _$GCreateCustomFieldData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + _i1.CustomField? _createCustomField; + _i1.CustomField? get createCustomField => _$this._createCustomField; + set createCustomField(_i1.CustomField? createCustomField) => + _$this._createCustomField = createCustomField; + + GCreateCustomFieldDataBuilder() { + GCreateCustomFieldData._initializeBuilder(this); + } + + GCreateCustomFieldDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _createCustomField = $v.createCustomField; + _$v = null; + } + return this; + } + + @override + void replace(GCreateCustomFieldData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GCreateCustomFieldData; + } + + @override + void update(void Function(GCreateCustomFieldDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GCreateCustomFieldData build() => _build(); + + _$GCreateCustomFieldData _build() { + final _$result = _$v ?? + new _$GCreateCustomFieldData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GCreateCustomFieldData', 'G__typename'), + createCustomField: createCustomField); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.req.gql.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.req.gql.dart new file mode 100644 index 00000000..14c9d9d5 --- /dev/null +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.req.gql.dart @@ -0,0 +1,42 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:end_to_end_test/variables/__generated__/create_custom_field.ast.gql.dart' + as _i2; +import 'package:end_to_end_test/variables/__generated__/create_custom_field.var.gql.dart' + as _i3; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'create_custom_field.req.gql.g.dart'; + +abstract class GCreateCustomField + implements Built { + GCreateCustomField._(); + + factory GCreateCustomField([Function(GCreateCustomFieldBuilder b) updates]) = + _$GCreateCustomField; + + static void _initializeBuilder(GCreateCustomFieldBuilder b) => b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'CreateCustomField', + ); + _i3.GCreateCustomFieldVars get vars; + _i1.Operation get operation; + static Serializer get serializer => + _$gCreateCustomFieldSerializer; + Map toJson() => (_i4.serializers.serializeWith( + GCreateCustomField.serializer, + this, + ) as Map); + static GCreateCustomField? fromJson(Map json) => + _i4.serializers.deserializeWith( + GCreateCustomField.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.req.gql.g.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.req.gql.g.dart new file mode 100644 index 00000000..0ab4ab8f --- /dev/null +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.req.gql.g.dart @@ -0,0 +1,180 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'create_custom_field.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gCreateCustomFieldSerializer = + new _$GCreateCustomFieldSerializer(); + +class _$GCreateCustomFieldSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GCreateCustomField, _$GCreateCustomField]; + @override + final String wireName = 'GCreateCustomField'; + + @override + Iterable serialize( + Serializers serializers, GCreateCustomField object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: const FullType(_i3.GCreateCustomFieldVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GCreateCustomField deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GCreateCustomFieldBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'vars': + result.vars.replace(serializers.deserialize(value, + specifiedType: const FullType(_i3.GCreateCustomFieldVars))! + as _i3.GCreateCustomFieldVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GCreateCustomField extends GCreateCustomField { + @override + final _i3.GCreateCustomFieldVars vars; + @override + final _i1.Operation operation; + + factory _$GCreateCustomField( + [void Function(GCreateCustomFieldBuilder)? updates]) => + (new GCreateCustomFieldBuilder()..update(updates))._build(); + + _$GCreateCustomField._({required this.vars, required this.operation}) + : super._() { + BuiltValueNullFieldError.checkNotNull(vars, r'GCreateCustomField', 'vars'); + BuiltValueNullFieldError.checkNotNull( + operation, r'GCreateCustomField', 'operation'); + } + + @override + GCreateCustomField rebuild( + void Function(GCreateCustomFieldBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GCreateCustomFieldBuilder toBuilder() => + new GCreateCustomFieldBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GCreateCustomField && + vars == other.vars && + operation == other.operation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GCreateCustomField') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GCreateCustomFieldBuilder + implements Builder { + _$GCreateCustomField? _$v; + + _i3.GCreateCustomFieldVarsBuilder? _vars; + _i3.GCreateCustomFieldVarsBuilder get vars => + _$this._vars ??= new _i3.GCreateCustomFieldVarsBuilder(); + set vars(_i3.GCreateCustomFieldVarsBuilder? vars) => _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GCreateCustomFieldBuilder() { + GCreateCustomField._initializeBuilder(this); + } + + GCreateCustomFieldBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GCreateCustomField other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GCreateCustomField; + } + + @override + void update(void Function(GCreateCustomFieldBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GCreateCustomField build() => _build(); + + _$GCreateCustomField _build() { + _$GCreateCustomField _$result; + try { + _$result = _$v ?? + new _$GCreateCustomField._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull( + operation, r'GCreateCustomField', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GCreateCustomField', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.dart new file mode 100644 index 00000000..28185eed --- /dev/null +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.dart @@ -0,0 +1,80 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart' + as _i1; +import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' + as _i2; + +part 'create_custom_field.var.gql.g.dart'; + +abstract class GCreateCustomFieldVars + implements Built { + GCreateCustomFieldVars._(); + + factory GCreateCustomFieldVars( + [Function(GCreateCustomFieldVarsBuilder b) updates]) = + _$GCreateCustomFieldVars; + + _i1.GCustomFieldInput get input; + Map toJson() => (_i2.serializers.serializeWith( + GCreateCustomFieldVars.serializer, + this, + ) as Map); + static GCreateCustomFieldVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GCreateCustomFieldVars.serializer, + json, + ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GCreateCustomFieldVarsSerializer(); +} + +class GCreateCustomFieldVarsSerializer + extends StructuredSerializer { + final String wireName = 'GCreateCustomFieldVars'; + + final Iterable types = const [ + GCreateCustomFieldVars, + _$GCreateCustomFieldVars + ]; + + Iterable serialize( + Serializers serializers, + GCreateCustomFieldVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('input'); + result.add(serializers.serialize(object.input, + specifiedType: const FullType(_i1.GCustomFieldInput))); + return result; + } + + GCreateCustomFieldVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GCreateCustomFieldVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'input': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i1.GCustomFieldInput)) + as _i1.GCustomFieldInput; + builder.input.replace(fieldValue); + break; + } + } + return builder.build(); + } +} diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.g.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.g.dart new file mode 100644 index 00000000..a4582afc --- /dev/null +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.g.dart @@ -0,0 +1,107 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'create_custom_field.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$GCreateCustomFieldVars extends GCreateCustomFieldVars { + @override + final _i1.GCustomFieldInput input; + + factory _$GCreateCustomFieldVars( + [void Function(GCreateCustomFieldVarsBuilder)? updates]) => + (new GCreateCustomFieldVarsBuilder()..update(updates))._build(); + + _$GCreateCustomFieldVars._({required this.input}) : super._() { + BuiltValueNullFieldError.checkNotNull( + input, r'GCreateCustomFieldVars', 'input'); + } + + @override + GCreateCustomFieldVars rebuild( + void Function(GCreateCustomFieldVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GCreateCustomFieldVarsBuilder toBuilder() => + new GCreateCustomFieldVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GCreateCustomFieldVars && input == other.input; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, input.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GCreateCustomFieldVars') + ..add('input', input)) + .toString(); + } +} + +class GCreateCustomFieldVarsBuilder + implements Builder { + _$GCreateCustomFieldVars? _$v; + + _i1.GCustomFieldInputBuilder? _input; + _i1.GCustomFieldInputBuilder get input => + _$this._input ??= new _i1.GCustomFieldInputBuilder(); + set input(_i1.GCustomFieldInputBuilder? input) => _$this._input = input; + + GCreateCustomFieldVarsBuilder(); + + GCreateCustomFieldVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _input = $v.input.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GCreateCustomFieldVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GCreateCustomFieldVars; + } + + @override + void update(void Function(GCreateCustomFieldVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GCreateCustomFieldVars build() => _build(); + + _$GCreateCustomFieldVars _build() { + _$GCreateCustomFieldVars _$result; + try { + _$result = _$v ?? new _$GCreateCustomFieldVars._(input: input.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'input'; + input.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GCreateCustomFieldVars', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_review.data.gql.g.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_review.data.gql.g.dart index bfa657d0..9a91b574 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/create_review.data.gql.g.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_review.data.gql.g.dart @@ -175,7 +175,11 @@ class _$GCreateReviewData extends GCreateReviewData { @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), createReview.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, createReview.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -300,10 +304,13 @@ class _$GCreateReviewData_createReview extends GCreateReviewData_createReview { @override int get hashCode { - return $jf($jc( - $jc($jc($jc(0, G__typename.hashCode), episode.hashCode), - stars.hashCode), - commentary.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, episode.hashCode); + _$hash = $jc(_$hash, stars.hashCode); + _$hash = $jc(_$hash, commentary.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -383,4 +390,4 @@ class GCreateReviewData_createReviewBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_review.req.gql.g.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_review.req.gql.g.dart index f3137423..a8262c04 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/create_review.req.gql.g.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_review.req.gql.g.dart @@ -90,7 +90,11 @@ class _$GCreateReview extends GCreateReview { @override int get hashCode { - return $jf($jc($jc(0, vars.hashCode), operation.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -167,4 +171,4 @@ class GCreateReviewBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.dart index 0448dd62..c1f5d3a1 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.dart @@ -7,7 +7,8 @@ import 'package:built_value/serializer.dart'; import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart' as _i1; import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' - as _i2; + as _i3; +import 'package:gql_exec/value.dart' as _i2; part 'create_review.var.gql.g.dart'; @@ -18,17 +19,71 @@ abstract class GCreateReviewVars factory GCreateReviewVars([Function(GCreateReviewVarsBuilder b) updates]) = _$GCreateReviewVars; - _i1.GEpisode? get episode; + _i2.Value<_i1.GEpisode>? get episode; _i1.GReviewInput get review; - static Serializer get serializer => - _$gCreateReviewVarsSerializer; - Map toJson() => (_i2.serializers.serializeWith( + Map toJson() => (_i3.serializers.serializeWith( GCreateReviewVars.serializer, this, ) as Map); static GCreateReviewVars? fromJson(Map json) => - _i2.serializers.deserializeWith( + _i3.serializers.deserializeWith( GCreateReviewVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GCreateReviewVarsSerializer(); +} + +class GCreateReviewVarsSerializer + extends StructuredSerializer { + final String wireName = 'GCreateReviewVars'; + + final Iterable types = const [GCreateReviewVars, _$GCreateReviewVars]; + + Iterable serialize( + Serializers serializers, + GCreateReviewVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + final _$episodevalue = object.episode; + if (_$episodevalue != null) { + result.add('episode'); + result.add(serializers.serialize(_$episodevalue!.value, + specifiedType: const FullType(_i1.GEpisode))); + } + result.add('review'); + result.add(serializers.serialize(object.review, + specifiedType: const FullType(_i1.GReviewInput))); + return result; + } + + GCreateReviewVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GCreateReviewVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'episode': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; + builder.episode = _i2.Value(fieldValue); + break; + case 'review': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i1.GReviewInput)) + as _i1.GReviewInput; + builder.review.replace(fieldValue); + break; + } + } + return builder.build(); + } } diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.g.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.g.dart index c697e3d7..6b8892bb 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.g.dart @@ -6,66 +6,9 @@ part of 'create_review.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** -Serializer _$gCreateReviewVarsSerializer = - new _$GCreateReviewVarsSerializer(); - -class _$GCreateReviewVarsSerializer - implements StructuredSerializer { - @override - final Iterable types = const [GCreateReviewVars, _$GCreateReviewVars]; - @override - final String wireName = 'GCreateReviewVars'; - - @override - Iterable serialize(Serializers serializers, GCreateReviewVars object, - {FullType specifiedType = FullType.unspecified}) { - final result = [ - 'review', - serializers.serialize(object.review, - specifiedType: const FullType(_i1.GReviewInput)), - ]; - Object? value; - value = object.episode; - if (value != null) { - result - ..add('episode') - ..add(serializers.serialize(value, - specifiedType: const FullType(_i1.GEpisode))); - } - return result; - } - - @override - GCreateReviewVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = new GCreateReviewVarsBuilder(); - - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current! as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'episode': - result.episode = serializers.deserialize(value, - specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode?; - break; - case 'review': - result.review.replace(serializers.deserialize(value, - specifiedType: const FullType(_i1.GReviewInput))! - as _i1.GReviewInput); - break; - } - } - - return result.build(); - } -} - class _$GCreateReviewVars extends GCreateReviewVars { @override - final _i1.GEpisode? episode; + final _i2.Value<_i1.GEpisode>? episode; @override final _i1.GReviewInput review; @@ -96,7 +39,11 @@ class _$GCreateReviewVars extends GCreateReviewVars { @override int get hashCode { - return $jf($jc($jc(0, episode.hashCode), review.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, episode.hashCode); + _$hash = $jc(_$hash, review.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -112,9 +59,9 @@ class GCreateReviewVarsBuilder implements Builder { _$GCreateReviewVars? _$v; - _i1.GEpisode? _episode; - _i1.GEpisode? get episode => _$this._episode; - set episode(_i1.GEpisode? episode) => _$this._episode = episode; + _i2.Value<_i1.GEpisode>? _episode; + _i2.Value<_i1.GEpisode>? get episode => _$this._episode; + set episode(_i2.Value<_i1.GEpisode>? episode) => _$this._episode = episode; _i1.GReviewInputBuilder? _review; _i1.GReviewInputBuilder get review => @@ -168,4 +115,4 @@ class GCreateReviewVarsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.data.gql.g.dart b/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.data.gql.g.dart index 45f31eee..4557ba55 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.data.gql.g.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.data.gql.g.dart @@ -163,7 +163,11 @@ class _$GHumanWithArgsData extends GHumanWithArgsData { @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), human.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, human.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -281,8 +285,12 @@ class _$GHumanWithArgsData_human extends GHumanWithArgsData_human { @override int get hashCode { - return $jf( - $jc($jc($jc(0, G__typename.hashCode), name.hashCode), height.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, height.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -354,4 +362,4 @@ class GHumanWithArgsData_humanBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.req.gql.g.dart b/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.req.gql.g.dart index 438ef3b0..4b085286 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.req.gql.g.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.req.gql.g.dart @@ -93,7 +93,11 @@ class _$GHumanWithArgs extends GHumanWithArgs { @override int get hashCode { - return $jf($jc($jc(0, vars.hashCode), operation.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -170,4 +174,4 @@ class GHumanWithArgsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.dart b/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.dart index fc19fdec..403b0010 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.dart @@ -17,8 +17,6 @@ abstract class GHumanWithArgsVars _$GHumanWithArgsVars; String get id; - static Serializer get serializer => - _$gHumanWithArgsVarsSerializer; Map toJson() => (_i1.serializers.serializeWith( GHumanWithArgsVars.serializer, this, @@ -28,4 +26,48 @@ abstract class GHumanWithArgsVars GHumanWithArgsVars.serializer, json, ); + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GHumanWithArgsVarsSerializer(); +} + +class GHumanWithArgsVarsSerializer + extends StructuredSerializer { + final String wireName = 'GHumanWithArgsVars'; + + final Iterable types = const [GHumanWithArgsVars, _$GHumanWithArgsVars]; + + Iterable serialize( + Serializers serializers, + GHumanWithArgsVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('id'); + result.add(serializers.serialize(object.id, + specifiedType: const FullType(String))); + return result; + } + + GHumanWithArgsVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GHumanWithArgsVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'id': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + builder.id = fieldValue; + break; + } + } + return builder.build(); + } } diff --git a/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.g.dart b/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.g.dart index e36ddcb1..907174cc 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.g.dart @@ -6,51 +6,6 @@ part of 'human_with_args.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** -Serializer _$gHumanWithArgsVarsSerializer = - new _$GHumanWithArgsVarsSerializer(); - -class _$GHumanWithArgsVarsSerializer - implements StructuredSerializer { - @override - final Iterable types = const [GHumanWithArgsVars, _$GHumanWithArgsVars]; - @override - final String wireName = 'GHumanWithArgsVars'; - - @override - Iterable serialize( - Serializers serializers, GHumanWithArgsVars object, - {FullType specifiedType = FullType.unspecified}) { - final result = [ - 'id', - serializers.serialize(object.id, specifiedType: const FullType(String)), - ]; - - return result; - } - - @override - GHumanWithArgsVars deserialize( - Serializers serializers, Iterable serialized, - {FullType specifiedType = FullType.unspecified}) { - final result = new GHumanWithArgsVarsBuilder(); - - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current! as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'id': - result.id = serializers.deserialize(value, - specifiedType: const FullType(String))! as String; - break; - } - } - - return result.build(); - } -} - class _$GHumanWithArgsVars extends GHumanWithArgsVars { @override final String id; @@ -80,7 +35,10 @@ class _$GHumanWithArgsVars extends GHumanWithArgsVars { @override int get hashCode { - return $jf($jc(0, id.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -133,4 +91,4 @@ class GHumanWithArgsVarsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/variables/create_custom_field.graphql b/codegen/end_to_end_test/lib/variables/create_custom_field.graphql new file mode 100644 index 00000000..d323ef49 --- /dev/null +++ b/codegen/end_to_end_test/lib/variables/create_custom_field.graphql @@ -0,0 +1,5 @@ + + +mutation CreateCustomField($input: CustomFieldInput!) { + createCustomField(input: $input) +} \ No newline at end of file diff --git a/codegen/end_to_end_test/pubspec.yaml b/codegen/end_to_end_test/pubspec.yaml index a1fb6f80..c91a20df 100644 --- a/codegen/end_to_end_test/pubspec.yaml +++ b/codegen/end_to_end_test/pubspec.yaml @@ -15,3 +15,38 @@ dev_dependencies: build: ^2.0.0 build_runner: ^2.0.0 test: ^1.16.8 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../../links/gql_exec + gql_link: + path: ../../links/gql_link + gql_websocket_link: + path: ../../links/gql_websocket_link + gql_transform_link: + path: ../../links/gql_transform_link + gql_http_link: + path: ../../links/gql_http_link + gql_error_link: + path: ../../links/gql_error_link + gql_code_builder: + path: ../gql_code_builder + gql_build: + path: ../gql_build + gql_example_http_auth_link: + path: ../../examples/gql_example_http_auth_link + gql_dio_link: + path: ../../links/gql_dio_link + gql_example_dio_link: + path: ../../examples/gql_example_dio_link + gql_example_cli_github: + path: ../../examples/gql_example_cli_github + gql_example_cli: + path: ../../examples/gql_example_cli + gql_example_build: + path: ../../examples/gql_example_build + gql_dedupe_link: + path: ../../links/gql_dedupe_link diff --git a/codegen/end_to_end_test/test/operation/variables_test.dart b/codegen/end_to_end_test/test/operation/variables_test.dart index f0d0a9ea..3d5840ef 100644 --- a/codegen/end_to_end_test/test/operation/variables_test.dart +++ b/codegen/end_to_end_test/test/operation/variables_test.dart @@ -1,3 +1,4 @@ +import 'package:gql_exec/value.dart'; import "package:test/test.dart"; import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart'; @@ -18,15 +19,14 @@ void main() { }); group("Complex Args", () { - final args = GCreateReviewVars( - (b) => b - ..episode = GEpisode.EMPIRE - ..review.stars = 5 - ..review.commentary = "this was amazing!!!" - ..review.favorite_color.blue = 255 - ..review.favorite_color.green = 120 - ..review.favorite_color.red = 80, - ); + final args = GCreateReviewVars((b) => b + ..episode = Value(GEpisode.EMPIRE) + ..review.stars = 5 + ..review.commentary = Value("this was amazing!!!") + ..review.favorite_color = Value(GColorInput((b) => b + ..blue = 255 + ..green = 120 + ..red = 80))); final json = { "episode": "EMPIRE", diff --git a/codegen/end_to_end_test/test/schema/input_test.dart b/codegen/end_to_end_test/test/schema/input_test.dart index 1d9bf6f6..3783c35e 100644 --- a/codegen/end_to_end_test/test/schema/input_test.dart +++ b/codegen/end_to_end_test/test/schema/input_test.dart @@ -1,3 +1,4 @@ +import 'package:gql_exec/value.dart'; import "package:test/test.dart"; import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart'; @@ -5,24 +6,22 @@ import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart'; void main() { group("Inputs", () { test('can be instantiated', () { - GReviewInput( - (b) => b - ..stars = 4 - ..commentary = "This was a great movie!" - ..favorite_color.red = 225 - ..favorite_color.blue = 255 - ..favorite_color.green = 123, - ); + GReviewInput((b) => b + ..stars = 4 + ..commentary = Value("This was a great movie!") + ..favorite_color = Value(GColorInput((b) => b + ..red = 225 + ..blue = 255 + ..green = 123))); }); test('can be serialized and deserialized', () { - final input = GReviewInput( - (b) => b - ..stars = 4 - ..favorite_color.red = 225 - ..favorite_color.blue = 255 - ..favorite_color.green = 123, - ); + final input = GReviewInput((b) => b + ..stars = 4 + ..favorite_color = Value(GColorInput((b) => b + ..red = 225 + ..blue = 255 + ..green = 123))); final json = { "stars": 4, "favorite_color": { diff --git a/codegen/end_to_end_test/test/schema/scalars_test.dart b/codegen/end_to_end_test/test/schema/scalars_test.dart index 5224ac69..6eab24ad 100644 --- a/codegen/end_to_end_test/test/schema/scalars_test.dart +++ b/codegen/end_to_end_test/test/schema/scalars_test.dart @@ -1,3 +1,6 @@ +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:gql_exec/value.dart'; import "package:test/test.dart"; import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart'; @@ -47,21 +50,19 @@ void main() { final scalar = GISODate(isoString); test('correctly serializes and deserializes', () { - expect(serializers.deserializeWith(GISODate.serializer, isoString), - equals(scalar)); - expect(serializers.serializeWith(GISODate.serializer, scalar), - equals(isoString)); + expect(serializers.deserializeWith(GISODate.serializer, isoString), equals(scalar)); + expect(serializers.serializeWith(GISODate.serializer, scalar), equals(isoString)); }); }); group("Custom scalars in input types", () { - final input = GReviewInput( - (b) => b - ..stars = 4 - ..seenOn.add(DateTime.fromMillisecondsSinceEpoch(1591892597000)), - ); + final input = GReviewInput((b) => b + ..stars = 4 + ..seenOn = Value( + BuiltList([DateTime.fromMillisecondsSinceEpoch(1591892597000)]), + )); test('correctly overrides scalars in input types', () { - expect(input.seenOn!.first, TypeMatcher()); + expect(input.seenOn!.value!.first, TypeMatcher()); }); test('can be serialized and deserialized with custom serializer', () { @@ -78,11 +79,11 @@ void main() { final vars = GReviewWithDateVars( (b) => b ..review.stars = 4 - ..createdAt = DateTime.fromMillisecondsSinceEpoch(1591892597000), + ..createdAt = Value(DateTime.fromMillisecondsSinceEpoch(1591892597000)), ); test('correctly overrides scalars in variable types', () { - expect(vars.createdAt, TypeMatcher()); + expect(vars.createdAt!.value, TypeMatcher()); }); test('can be serialized and deserialized with custom serializer', () { @@ -101,11 +102,8 @@ void main() { final data = GReviewWithDateData( (b) => b ..createReview.stars = 1 - ..createReview - .seenOn - .add(DateTime.fromMillisecondsSinceEpoch(1591892597000)) - ..createReview.createdAt = - DateTime.fromMillisecondsSinceEpoch(1591892597000), + ..createReview.seenOn.add(DateTime.fromMillisecondsSinceEpoch(1591892597000)) + ..createReview.createdAt = DateTime.fromMillisecondsSinceEpoch(1591892597000), ); test('correctly overrides scalars in data types', () { diff --git a/codegen/gql_build/README.md b/codegen/gql_build/README.md index 86acaf98..7ce876c6 100644 --- a/codegen/gql_build/README.md +++ b/codegen/gql_build/README.md @@ -63,6 +63,20 @@ new enum values are added to the schema and the client has not updated to the ne `global_enum_fallbacks`: \[bool\] Add a generated fallback value for each enum value (except for ones that have a custom fallback value specified in the enum_fallbacks map). Defaults to false. +`when_extensions`: [Map\] whether to enable the `when`/`maybeWhen` extension on the generated data classes +from inline fragment spreads with type conditions. +Supported keys are `when` and `maybeWhen`, and the values are booleans indicating whether to enable +generation of the extension method not. + + +Example: + +```yaml +when_extensions: + when: true # enable the `when` extension method + maybeWhen: true # enable the `maybeWhen` extension method +``` + Example: ```yaml diff --git a/codegen/gql_build/lib/src/schema_builder.dart b/codegen/gql_build/lib/src/schema_builder.dart index b7054dd5..c7e2cfca 100644 --- a/codegen/gql_build/lib/src/schema_builder.dart +++ b/codegen/gql_build/lib/src/schema_builder.dart @@ -2,6 +2,7 @@ import "dart:async"; import "package:build/build.dart"; import "package:code_builder/code_builder.dart"; +import "package:gql_build/src/allocators/gql_allocator.dart"; import "package:gql_code_builder/schema.dart"; import "package:path/path.dart"; @@ -14,11 +15,7 @@ class SchemaBuilder implements Builder { final EnumFallbackConfig enumFallbackConfig; final bool generatePossibleTypesMap; - SchemaBuilder( - this.typeOverrides, - this.enumFallbackConfig, - this.generatePossibleTypesMap, - ); + SchemaBuilder(this.typeOverrides, this.enumFallbackConfig, this.generatePossibleTypesMap); @override Map> get buildExtensions => { @@ -29,24 +26,20 @@ class SchemaBuilder implements Builder { FutureOr build(BuildStep buildStep) async { final doc = await readDocument(buildStep); - final generatedPartUrl = buildStep.inputId - .changeExtension(generatedFileExtension(schemaExtension)) - .uri - .path; + final generatedPartUrl = + buildStep.inputId.changeExtension(generatedFileExtension(schemaExtension)).uri.path; - final library = buildSchemaLibrary( - doc, - basename(generatedPartUrl), - typeOverrides, - enumFallbackConfig, - generatePossibleTypesMap: generatePossibleTypesMap, - ); - - return writeDocument( - library, - buildStep, - schemaExtension, + final schemaUrl = outputAssetId(buildStep.inputId, schemaExtension).uri.toString(); + final allocator = GqlAllocator( + buildStep.inputId.uri.toString(), outputAssetId(buildStep.inputId, schemaExtension).uri.toString(), + schemaUrl, ); + + final library = buildSchemaLibrary( + doc, basename(generatedPartUrl), typeOverrides, enumFallbackConfig, + generatePossibleTypesMap: generatePossibleTypesMap, allocator: allocator); + + return writeDocument(library, buildStep, schemaExtension, schemaUrl, allocator); } } diff --git a/codegen/gql_build/lib/src/serializer_builder.dart b/codegen/gql_build/lib/src/serializer_builder.dart index 22028a04..b9d49762 100644 --- a/codegen/gql_build/lib/src/serializer_builder.dart +++ b/codegen/gql_build/lib/src/serializer_builder.dart @@ -29,10 +29,9 @@ class SerializerBuilder implements Builder { static final _generatedFiles = Glob("lib/**.gql.dart"); // create a path for the serializers output in same directory as schema - List get pathSegments => - outputAssetId(schemaId, serializerExtension).pathSegments - ..removeLast() - ..add("serializers.gql.dart"); + List get pathSegments => outputAssetId(schemaId, serializerExtension).pathSegments + ..removeLast() + ..add("serializers.gql.dart"); @override Map> get buildExtensions => { @@ -42,29 +41,32 @@ class SerializerBuilder implements Builder { @override FutureOr build(BuildStep buildStep) async { + final allocator = PickAllocator( + doNotPick: ["package:built_value/serializer.dart"], + include: [ + "package:built_collection/built_collection.dart", + ...typeOverrides.values.map((ref) => ref.url).whereType() + ], + ); + /// BuiltValue classes with serializers. These will be added automatically /// using `@SerializersFor`. - final builtClasses = - SplayTreeSet((a, b) => a.name.compareTo(b.name)); + final builtClasses = SplayTreeSet((a, b) => a.name.compareTo(b.name)); /// Non BuiltValue classes with serializers (i.e. inline fragment classes). /// These need to be added manually since `@SerializersFor` only recognizes /// BuiltValue classes. - final nonBuiltClasses = - SplayTreeSet((a, b) => a.name.compareTo(b.name)); + final nonBuiltClasses = SplayTreeSet((a, b) => a.name.compareTo(b.name)); final hasSerializer = (ClassElement c) => c.fields.any((field) => field.isStatic && field.name == "serializer" && field.type.element?.name == "Serializer" && - field.type.element?.source?.uri.toString() == - "package:built_value/serializer.dart"); + field.type.element?.source?.uri.toString() == "package:built_value/serializer.dart"); final isBuiltValue = (ClassElement c) => c.allSupertypes.any((interface) => - (interface.element.name == "Built" || - interface.element.name == "EnumClass") && - interface.element.source.uri.toString() == - "package:built_value/built_value.dart"); + (interface.element.name == "Built" || interface.element.name == "EnumClass") && + interface.element.source.uri.toString() == "package:built_value/built_value.dart"); await for (final input in buildStep.findAssets(_generatedFiles)) { final lib = await buildStep.resolver.libraryFor(input); @@ -102,13 +104,7 @@ class SerializerBuilder implements Builder { ); final _emitter = DartEmitter( - allocator: PickAllocator( - doNotPick: ["package:built_value/serializer.dart"], - include: [ - "package:built_collection/built_collection.dart", - ...typeOverrides.values.map((ref) => ref.url).whereType() - ], - ), + allocator: allocator, orderDirectives: true, useNullSafetySyntax: true, ); diff --git a/codegen/gql_build/lib/src/utils/writer.dart b/codegen/gql_build/lib/src/utils/writer.dart index a1285154..ba901931 100644 --- a/codegen/gql_build/lib/src/utils/writer.dart +++ b/codegen/gql_build/lib/src/utils/writer.dart @@ -14,18 +14,21 @@ Future writeDocument( BuildStep buildStep, String extension, [ String? schemaUrl, + Allocator? allocator, ]) { if (library.body.isEmpty) return Future.value(null); + allocator ??= GqlAllocator( + buildStep.inputId.uri.toString(), + outputAssetId(buildStep.inputId, extension).uri.toString(), + schemaUrl, + ); + final generatedAsset = outputAssetId(buildStep.inputId, extension); final genSrc = _dartfmt.format("${library.accept( DartEmitter( - allocator: GqlAllocator( - buildStep.inputId.uri.toString(), - generatedAsset.uri.toString(), - schemaUrl, - ), + allocator: allocator, orderDirectives: true, useNullSafetySyntax: true, ), diff --git a/codegen/gql_build/lib/src/var_builder.dart b/codegen/gql_build/lib/src/var_builder.dart index 74ba44dc..c6f9c4d0 100644 --- a/codegen/gql_build/lib/src/var_builder.dart +++ b/codegen/gql_build/lib/src/var_builder.dart @@ -2,6 +2,7 @@ import "dart:async"; import "package:build/build.dart"; import "package:code_builder/code_builder.dart"; +import "package:gql_build/src/allocators/gql_allocator.dart"; import "package:gql_code_builder/var.dart"; import "package:path/path.dart"; @@ -29,23 +30,25 @@ class VarBuilder implements Builder { final doc = await readDocument(buildStep); final schema = await readDocument(buildStep, schemaId); - final generatedPartUrl = buildStep.inputId - .changeExtension(generatedFileExtension(varExtension)) - .uri - .path; + final generatedPartUrl = + buildStep.inputId.changeExtension(generatedFileExtension(varExtension)).uri.path; - final library = buildVarLibrary( - doc, - addTypenames(schema), - basename(generatedPartUrl), - typeOverrides, + final schemaUrl = outputAssetId(schemaId, schemaExtension).uri.toString(); + final allocator = GqlAllocator( + buildStep.inputId.uri.toString(), + outputAssetId(buildStep.inputId, schemaExtension).uri.toString(), + schemaUrl, ); + final library = buildVarLibrary( + doc, addTypenames(schema), basename(generatedPartUrl), typeOverrides, allocator); + return writeDocument( library, buildStep, varExtension, - outputAssetId(schemaId, schemaExtension).uri.toString(), + schemaUrl, + allocator, ); } } diff --git a/codegen/gql_build/pubspec.yaml b/codegen/gql_build/pubspec.yaml index 17582bd3..3012d6cf 100644 --- a/codegen/gql_build/pubspec.yaml +++ b/codegen/gql_build/pubspec.yaml @@ -20,3 +20,38 @@ dependencies: dev_dependencies: build_test: ^2.0.0 gql_pedantic: ^1.0.2 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../../links/gql_exec + gql_link: + path: ../../links/gql_link + gql_websocket_link: + path: ../../links/gql_websocket_link + gql_transform_link: + path: ../../links/gql_transform_link + gql_http_link: + path: ../../links/gql_http_link + gql_error_link: + path: ../../links/gql_error_link + gql_code_builder: + path: ../gql_code_builder + gql_example_http_auth_link: + path: ../../examples/gql_example_http_auth_link + gql_dio_link: + path: ../../links/gql_dio_link + gql_example_dio_link: + path: ../../examples/gql_example_dio_link + gql_example_cli_github: + path: ../../examples/gql_example_cli_github + gql_example_cli: + path: ../../examples/gql_example_cli + gql_example_build: + path: ../../examples/gql_example_build + gql_dedupe_link: + path: ../../links/gql_dedupe_link + end_to_end_test: + path: ../end_to_end_test diff --git a/codegen/gql_code_builder/lib/schema.dart b/codegen/gql_code_builder/lib/schema.dart index 61a57957..71b22952 100644 --- a/codegen/gql_code_builder/lib/schema.dart +++ b/codegen/gql_code_builder/lib/schema.dart @@ -7,17 +7,14 @@ import "package:gql_code_builder/src/utils/possible_types.dart"; export "package:gql_code_builder/src/config/enum_fallback_config.dart"; -Library buildSchemaLibrary( - SourceNode schemaSource, - String partUrl, - Map typeOverrides, - EnumFallbackConfig enumFallbackConfig, { - bool generatePossibleTypesMap = false, -}) { +Library buildSchemaLibrary(SourceNode schemaSource, String partUrl, + Map typeOverrides, EnumFallbackConfig enumFallbackConfig, + {bool generatePossibleTypesMap = false, Allocator? allocator}) { final lib = buildSchema( schemaSource, typeOverrides, enumFallbackConfig, + allocator ?? Allocator(), ) as Library; final Code? possibleTypes; @@ -45,8 +42,7 @@ Code buildPossibleTypes(DocumentNode document) { // wrap the map in a literal for codegen final possibleTypesLiteral = literalMap(possibleTypesMap); // assign the literal to a const variable named "possibleTypes" - return declareConst("possibleTypesMap", - type: Reference("Map>")) + return declareConst("possibleTypesMap", type: Reference("Map>")) .assign(possibleTypesLiteral) .statement; } diff --git a/codegen/gql_code_builder/lib/src/built_class.dart b/codegen/gql_code_builder/lib/src/built_class.dart index 631ba97b..48f75e34 100644 --- a/codegen/gql_code_builder/lib/src/built_class.dart +++ b/codegen/gql_code_builder/lib/src/built_class.dart @@ -11,6 +11,7 @@ Class builtClass({ Map? initializers, Map superclassSelections = const {}, List methods = const [], + bool hasCustomSerializer = false, }) { final className = builtClassName(name); return Class( @@ -76,7 +77,8 @@ Class builtClass({ ).code, ), if (getters != null) ...getters, - // Serlialization methods + // Serialization methods + if(!hasCustomSerializer) buildSerializerGetter(className).rebuild( (b) => b..body = Code("_\$${toCamelCase(className)}Serializer"), ), diff --git a/codegen/gql_code_builder/lib/src/common.dart b/codegen/gql_code_builder/lib/src/common.dart index 7cbcd01a..ce9d5d4e 100644 --- a/codegen/gql_code_builder/lib/src/common.dart +++ b/codegen/gql_code_builder/lib/src/common.dart @@ -93,9 +93,6 @@ Reference _typeRef(TypeNode type, Map typeMap) { (b) => b ..url = ref.url ..symbol = ref.symbol - - /// TODO: remove `inList` check - /// https://github.com/google/built_value.dart/issues/1011#issuecomment-804843573 ..isNullable = !type.isNonNull, ); } else if (type is ListTypeNode) { @@ -180,6 +177,36 @@ Method buildGetter({ ); } +Method buildOptionalGetter({ + required NameNode nameNode, + required TypeNode typeNode, + required SourceNode schemaSource, + Map typeOverrides = const {}, + String? typeRefPrefix, + bool built = true, + bool isOverride = false, +}) { + final baseGetter = buildGetter( + nameNode: nameNode, + typeNode: typeNode, + schemaSource: schemaSource, + typeOverrides: typeOverrides, + typeRefPrefix: typeRefPrefix, + built: built, + isOverride: isOverride, + ); + + if (typeNode.isNonNull) return baseGetter; + + final optionalGetter = baseGetter.rebuild((b) => b + ..returns = TypeReference((b2) => b2 + ..isNullable = true + ..url = "package:gql_exec/value.dart" + ..symbol = "Value" + ..types.add((baseGetter.returns as TypeReference).rebuild((b3) => b3..isNullable = false)))); + return optionalGetter; +} + Method buildSerializerGetter(String className) => Method( (b) => b ..static = true @@ -236,6 +263,5 @@ Method buildFromJsonGetter(String className) => Method( ..lambda = true ..body = refer("serializers", "#serializer") .property("deserializeWith") - .call( - [refer(className).property("serializer"), refer("json")]).code, + .call([refer(className).property("serializer"), refer("json")]).code, ); diff --git a/codegen/gql_code_builder/lib/src/schema.dart b/codegen/gql_code_builder/lib/src/schema.dart index aa9eb78b..90307d4d 100644 --- a/codegen/gql_code_builder/lib/src/schema.dart +++ b/codegen/gql_code_builder/lib/src/schema.dart @@ -1,5 +1,6 @@ import "package:code_builder/code_builder.dart"; import "package:gql/ast.dart"; +import "package:gql_code_builder/var.dart"; import "./schema/enum.dart"; import "./schema/input.dart"; @@ -12,69 +13,65 @@ Spec? buildSchema( SourceNode schemaSource, Map typeOverrides, EnumFallbackConfig enumFallbackConfig, + Allocator allocator, ) => - schemaSource.document.accept( - _SchemaBuilderVisitor( - schemaSource, - typeOverrides, - enumFallbackConfig, - ), - ); + schemaSource.document + .accept( + _SchemaBuilderVisitor( + schemaSource, + typeOverrides, + enumFallbackConfig, + allocator, + ), + ) + ?.first; -class _SchemaBuilderVisitor extends SimpleVisitor { +class _SchemaBuilderVisitor extends SimpleVisitor?> { final SourceNode schemaSource; final Map typeOverrides; final EnumFallbackConfig enumFallbackConfig; + final Allocator allocator; _SchemaBuilderVisitor( - this.schemaSource, - this.typeOverrides, - this.enumFallbackConfig, - ); - - Spec? _acceptOne( - Node? node, - ) => - node != null ? node.accept(this) : literalNull; - - List _acceptMany( - List nodes, - ) => - nodes.map(_acceptOne).toList( - growable: false, - ); + this.schemaSource, this.typeOverrides, this.enumFallbackConfig, this.allocator); @override - Spec visitDocumentNode( + List visitDocumentNode( DocumentNode node, ) => - Library( - (b) => b.body.addAll( - _acceptMany(node.definitions).whereType(), - ), - ); + [ + Library( + (b) => b.body.addAll( + node.definitions.expand( + (node) => node.accept(this) ?? [], + ), + ), + ) + ]; @override - Spec visitInputObjectTypeDefinitionNode( + List visitInputObjectTypeDefinitionNode( InputObjectTypeDefinitionNode node, - ) => - buildInputClass( - node, - schemaSource, - typeOverrides, - ); + ) { + final inputClass = buildInputClass( + node, + schemaSource, + typeOverrides, + ); + final serializer = + nullAwareJsonSerializerClass(inputClass, allocator, schemaSource, typeOverrides); + return [inputClass, serializer]; + } @override - Spec? visitScalarTypeDefinitionNode( + List visitScalarTypeDefinitionNode( ScalarTypeDefinitionNode node, ) => - typeOverrides.containsKey(node.name.value) - ? null - : buildScalarClass(node); + typeOverrides.containsKey(node.name.value) ? [] : [buildScalarClass(node)]; @override - Spec visitEnumTypeDefinitionNode( + List visitEnumTypeDefinitionNode( EnumTypeDefinitionNode node, ) => - buildEnumClass(node, enumFallbackConfig); + [buildEnumClass(node, enumFallbackConfig)]; } diff --git a/codegen/gql_code_builder/lib/src/schema/input.dart b/codegen/gql_code_builder/lib/src/schema/input.dart index bce9faa7..b42997fb 100644 --- a/codegen/gql_code_builder/lib/src/schema/input.dart +++ b/codegen/gql_code_builder/lib/src/schema/input.dart @@ -1,5 +1,6 @@ import "package:code_builder/code_builder.dart"; import "package:gql/ast.dart"; +import "package:gql_code_builder/var.dart"; import "../../source.dart"; import "../built_class.dart"; @@ -8,17 +9,20 @@ import "../common.dart"; List buildInputClasses( SourceNode schemaSource, Map typeOverrides, + Allocator allocator, ) => schemaSource.document.definitions .whereType() - .map( - (InputObjectTypeDefinitionNode node) => buildInputClass( - node, - schemaSource, - typeOverrides, - ), - ) - .toList(); + .expand((InputObjectTypeDefinitionNode node) { + final inputClass = buildInputClass( + node, + schemaSource, + typeOverrides, + ); + final serializer = + nullAwareJsonSerializerClass(inputClass, allocator, schemaSource, typeOverrides); + return [inputClass, serializer]; + }).toList(); Class buildInputClass( InputObjectTypeDefinitionNode node, @@ -28,11 +32,15 @@ Class buildInputClass( builtClass( name: node.name.value, getters: node.fields.map( - (node) => buildGetter( + (node) => buildOptionalGetter( nameNode: node.name, typeNode: node.type, schemaSource: schemaSource, typeOverrides: typeOverrides, ), ), + hasCustomSerializer: true, + methods: [ + nullAwareJsonSerializerField(node, "G${node.name.value}"), + ], ); diff --git a/codegen/gql_code_builder/lib/var.dart b/codegen/gql_code_builder/lib/var.dart index 80f553c7..2e5ca1e1 100644 --- a/codegen/gql_code_builder/lib/var.dart +++ b/codegen/gql_code_builder/lib/var.dart @@ -1,4 +1,5 @@ import "package:code_builder/code_builder.dart"; +import "package:collection/collection.dart"; import "package:gql/ast.dart"; import "./source.dart"; @@ -11,34 +12,34 @@ Library buildVarLibrary( SourceNode schemaSource, String partUrl, Map typeOverrides, + Allocator allocator, ) { final operationVarClasses = docSource.document.definitions .whereType() - .map( - (op) => builtClass( - name: "${op.name!.value}Vars", - getters: op.variableDefinitions.map( - (node) => buildGetter( - nameNode: node.variable.name, - typeNode: node.type, - schemaSource: schemaSource, - typeOverrides: typeOverrides, - ), - ), - ), - ) + .map((op) => builtClass( + name: "${op.name!.value}Vars", + getters: op.variableDefinitions.map( + (node) => buildOptionalGetter( + nameNode: node.variable.name, + typeNode: node.type, + schemaSource: schemaSource, + typeOverrides: typeOverrides, + ), + ), + hasCustomSerializer: true, + methods: [ + nullAwareJsonSerializerField(op, "G${op.name!.value}Vars"), + ])) .toList(); Map _fragmentMap(SourceNode source) => { - for (var def - in source.document.definitions.whereType()) + for (var def in source.document.definitions.whereType()) def.name.value: def, for (var import in source.imports) ..._fragmentMap(import) }; - final fragmentVarClasses = docSource.document.definitions - .whereType() - .map((frag) { + final fragmentVarClasses = + docSource.document.definitions.whereType().map((frag) { final varTypes = fragmentVarTypes( fragment: frag, fragmentMap: _fragmentMap(docSource), @@ -47,13 +48,17 @@ Library buildVarLibrary( return builtClass( name: "${frag.name.value}Vars", getters: varTypes.entries.map( - (entry) => buildGetter( + (entry) => buildOptionalGetter( nameNode: entry.key, typeNode: entry.value, schemaSource: schemaSource, typeOverrides: typeOverrides, ), ), + hasCustomSerializer: true, + methods: [ + nullAwareJsonSerializerField(frag, "G${frag.name.value}Vars"), + ], ); }).toList(); @@ -63,6 +68,230 @@ Library buildVarLibrary( ..body.addAll([ ...operationVarClasses, ...fragmentVarClasses, + for (var op in operationVarClasses) + nullAwareJsonSerializerClass( + op, + allocator, + schemaSource, + typeOverrides, + ), + for (var frag in fragmentVarClasses) + nullAwareJsonSerializerClass( + frag, + allocator, + schemaSource, + typeOverrides, + ), ]), ); } + +Method nullAwareJsonSerializerField(Node op, String className) => Method((b) => b + ..annotations + .add(CodeExpression(Code("BuiltValueSerializer(custom: true, serializeNulls: true)"))) + ..static = true + ..type = MethodType.getter + ..lambda = true + ..returns = TypeReference((b2) => b2 + ..symbol = "Serializer" + ..url = "package:built_value/serializer.dart" + ..types.add(refer(className))) + ..name = "serializer" + ..body = Code("${className}Serializer()")); + +Class nullAwareJsonSerializerClass( + Class base, + Allocator allocator, + SourceNode schemaSource, + Map typeOverrides, +) => + Class((b) => b + ..name = "${base.name}Serializer" + ..extend = TypeReference((b) => b + ..symbol = "StructuredSerializer" + ..url = "package:built_value/serializer.dart" + ..types.add(refer(base.name))) + ..fields.addAll([ + Field( + (b) => b + ..name = "wireName" + ..modifier = FieldModifier.final$ + ..type = refer("String") + ..assignment = (literalString(base.name)).code, + ), + Field((b) => b + ..name = "types" + ..modifier = FieldModifier.final$ + ..type = TypeReference((b2) => b2..symbol = "Iterable") + ..assignment = Code("const [${base.name}, _\$${base.name}]")) + ]) + ..methods.addAll([ + Method((b) => b + ..name = "serialize" + ..returns = refer("Iterable") + ..requiredParameters.add(Parameter((b) => b + ..name = "serializers" + ..type = refer("Serializers", "package:built_value/serializer.dart"))) + ..requiredParameters.add(Parameter((b) => b + ..name = "object" + ..type = refer(base.name))) + ..optionalParameters.add(Parameter((b) => b + ..name = "specifiedType" + ..named = true + ..type = refer("FullType", "package:built_value/serializer.dart") + ..defaultTo = Code("FullType.unspecified"))) + ..body = _serializerBody(base, allocator, schemaSource, typeOverrides)), + Method((b) => b + ..name = "deserialize" + ..returns = refer(base.name) + ..requiredParameters.add(Parameter((b) => b + ..name = "serializers" + ..type = refer("Serializers", "package:built_value/serializer.dart"))) + ..requiredParameters.add(Parameter((b) => b + ..name = "serialized" + ..type = refer("Iterable"))) + ..optionalParameters.add(Parameter((b) => b + ..name = "specifiedType" + ..named = true + ..type = refer("FullType", "package:built_value/serializer.dart") + ..defaultTo = Code("FullType.unspecified"))) + ..body = _deserializerBody(base, allocator, schemaSource, typeOverrides)), + ])); + +Code _serializerBody(Class base, Allocator allocator, SourceNode schemaSource, + Map typeOverrides) { + final vars = []; + + for (final field + in base.methods.where((field) => !field.static && field.type == MethodType.getter)) { + final isOptionalValue = isValue(field.returns!); + final statements = []; + + if (isOptionalValue) { + final realType = (field.returns as TypeReference).types.first as TypeReference; + + final _valueVarName = "_\$${field.name}value"; + + statements.add(Code("final $_valueVarName = object.${field.name};")); + statements.add(Code("if ($_valueVarName != null) {")); + statements.add(Code("result.add('${_getWireName(field)}');")); + statements.add(Code( + "result.add(serializers.serialize($_valueVarName!.value, specifiedType: const ${_generateFullType(realType, allocator)}));")); + statements.add(Code("}")); + } else { + statements.add(Code("result.add('${_getWireName(field)}');")); + statements.add(Code( + "result.add(serializers.serialize(object.${field.name}, specifiedType: const ${_generateFullType(field.returns as TypeReference, allocator)}));")); + } + vars.add(Block.of(statements)); + } + + final body = Block.of([ + Code("final result = [];"), + ...vars, + Code("return result;"), + ]); + + return body; +} + +Code _deserializerBody(Class base, Allocator allocator, SourceNode schemaSource, + Map typeOverrides) => + Code("""final builder = ${base.name}Builder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + ${_generateFieldDeserializers( + base, + allocator, + schemaSource, + typeOverrides, + )} + } + } + return builder.build(); + """); + +String _generateFieldDeserializers( + Class clazz, + Allocator allocator, + SourceNode schemaSource, + Map typeOverrides, +) => + clazz.methods.where((field) => field.type == MethodType.getter && !field.static).map((field) { + var type = field.returns!; + final isWrappedValue = isValue(type); + if (isWrappedValue) { + type = (type as TypeReference).types.first; + } + final fullType = _generateFullType(type as TypeReference, allocator); + + final typeDefNode = getTypeDefinitionNode(schemaSource.document, type.symbol.substring(1)); + + print(typeDefNode.runtimeType.toString() + " " + (typeDefNode?.name.value.toString() ?? "")); + + //TODO this feels flaky, find a better way + final isBuilder = type.url != null && + !isWrappedValue && + (typeDefNode is! ScalarTypeDefinitionNode && typeDefNode is! EnumTypeDefinitionNode); + + /// TODO check for wireName + + var base = """ +case '${_getWireName(field)}': + var fieldValue = serializers.deserialize( + value, specifiedType: const $fullType) as ${_generateTypeCast(type, allocator)};"""; + + if (isBuilder) { + base += """ + builder.${field.name}.replace(fieldValue); + """; + } else { + base += """ + builder.${field.name} = ${isWrappedValue ? "${allocator.allocate(_valueTypeRef)}(fieldValue)" : "fieldValue"}; + """; + } + + return base + + """ +break; +"""; + }).join(); + +Code _generateFullType(TypeReference ref, Allocator allocator) { + if (ref.types.isEmpty) { + return Code("FullType(${allocator.allocate(ref)})"); + } else { + return Code( + "FullType(${allocator.allocate(ref)}, [${ref.types.map((t) => _generateFullType(t as TypeReference, allocator)).join(",")}])"); + } +} + +String _generateTypeCast(TypeReference ref, Allocator allocator) { + if (ref.types.isEmpty) { + return allocator.allocate(ref); + } else { + return "${allocator.allocate(ref)}<${ref.types.map((t) => _generateTypeCast(t as TypeReference, allocator)).join(",")}>"; + } +} + +final _valueTypeRef = TypeReference((b) => b + ..symbol = "Value" + ..url = "package:gql_exec/value.dart"); + +bool isValue(Reference ref) { + if (ref is! TypeReference) return false; + + return ref.symbol == _valueTypeRef.symbol && ref.url == _valueTypeRef.url; +} + +String _getWireName(Method m) { + final annotation = + m.annotations.firstWhereOrNull((a) => a is InvokeExpression && a.name == "BuiltValueField") + as InvokeExpression?; + if (annotation == null) return m.name!; + return (annotation.namedArguments["wireName"] as LiteralExpression?)?.literal ?? m.name!; +} diff --git a/codegen/gql_code_builder/pubspec.yaml b/codegen/gql_code_builder/pubspec.yaml index 4f7e855a..1150c2d9 100644 --- a/codegen/gql_code_builder/pubspec.yaml +++ b/codegen/gql_code_builder/pubspec.yaml @@ -17,3 +17,38 @@ dev_dependencies: build_runner: ^2.1.0 gql_pedantic: ^1.0.2 test: ^1.16.8 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../../links/gql_exec + gql_link: + path: ../../links/gql_link + gql_websocket_link: + path: ../../links/gql_websocket_link + gql_transform_link: + path: ../../links/gql_transform_link + gql_http_link: + path: ../../links/gql_http_link + gql_error_link: + path: ../../links/gql_error_link + gql_build: + path: ../gql_build + gql_example_http_auth_link: + path: ../../examples/gql_example_http_auth_link + gql_dio_link: + path: ../../links/gql_dio_link + gql_example_dio_link: + path: ../../examples/gql_example_dio_link + gql_example_cli_github: + path: ../../examples/gql_example_cli_github + gql_example_cli: + path: ../../examples/gql_example_cli + gql_example_build: + path: ../../examples/gql_example_build + gql_dedupe_link: + path: ../../links/gql_dedupe_link + end_to_end_test: + path: ../end_to_end_test diff --git a/examples/gql_example_build/pubspec.yaml b/examples/gql_example_build/pubspec.yaml index 54cac320..f0e24baf 100644 --- a/examples/gql_example_build/pubspec.yaml +++ b/examples/gql_example_build/pubspec.yaml @@ -6,3 +6,38 @@ dev_dependencies: gql_build: ^0.7.0 gql_pedantic: ^1.0.2 test: ^1.0.0 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../../links/gql_exec + gql_link: + path: ../../links/gql_link + gql_websocket_link: + path: ../../links/gql_websocket_link + gql_transform_link: + path: ../../links/gql_transform_link + gql_http_link: + path: ../../links/gql_http_link + gql_error_link: + path: ../../links/gql_error_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_example_http_auth_link: + path: ../gql_example_http_auth_link + gql_dio_link: + path: ../../links/gql_dio_link + gql_example_dio_link: + path: ../gql_example_dio_link + gql_example_cli_github: + path: ../gql_example_cli_github + gql_example_cli: + path: ../gql_example_cli + gql_dedupe_link: + path: ../../links/gql_dedupe_link + end_to_end_test: + path: ../../codegen/end_to_end_test diff --git a/examples/gql_example_cli/pubspec.yaml b/examples/gql_example_cli/pubspec.yaml index 64075f49..26c96d5d 100644 --- a/examples/gql_example_cli/pubspec.yaml +++ b/examples/gql_example_cli/pubspec.yaml @@ -11,3 +11,38 @@ dev_dependencies: build_runner: ^2.0.0 gql_build: ^0.7.0 gql_pedantic: ^1.0.2 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../../links/gql_exec + gql_link: + path: ../../links/gql_link + gql_websocket_link: + path: ../../links/gql_websocket_link + gql_transform_link: + path: ../../links/gql_transform_link + gql_http_link: + path: ../../links/gql_http_link + gql_error_link: + path: ../../links/gql_error_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_example_http_auth_link: + path: ../gql_example_http_auth_link + gql_dio_link: + path: ../../links/gql_dio_link + gql_example_dio_link: + path: ../gql_example_dio_link + gql_example_cli_github: + path: ../gql_example_cli_github + gql_example_build: + path: ../gql_example_build + gql_dedupe_link: + path: ../../links/gql_dedupe_link + end_to_end_test: + path: ../../codegen/end_to_end_test diff --git a/examples/gql_example_cli_github/pubspec.yaml b/examples/gql_example_cli_github/pubspec.yaml index c2223123..7d0449d4 100644 --- a/examples/gql_example_cli_github/pubspec.yaml +++ b/examples/gql_example_cli_github/pubspec.yaml @@ -12,3 +12,38 @@ dev_dependencies: build_runner: ^2.0.0 gql_build: ^0.7.0 gql_pedantic: ^1.0.2 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../../links/gql_exec + gql_link: + path: ../../links/gql_link + gql_websocket_link: + path: ../../links/gql_websocket_link + gql_transform_link: + path: ../../links/gql_transform_link + gql_http_link: + path: ../../links/gql_http_link + gql_error_link: + path: ../../links/gql_error_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_example_http_auth_link: + path: ../gql_example_http_auth_link + gql_dio_link: + path: ../../links/gql_dio_link + gql_example_dio_link: + path: ../gql_example_dio_link + gql_example_cli: + path: ../gql_example_cli + gql_example_build: + path: ../gql_example_build + gql_dedupe_link: + path: ../../links/gql_dedupe_link + end_to_end_test: + path: ../../codegen/end_to_end_test diff --git a/examples/gql_example_dio_link/pubspec.yaml b/examples/gql_example_dio_link/pubspec.yaml index eb1dfbea..b3da1bc5 100644 --- a/examples/gql_example_dio_link/pubspec.yaml +++ b/examples/gql_example_dio_link/pubspec.yaml @@ -8,3 +8,38 @@ dependencies: gql_link: ^0.5.0 gql_exec: ^0.4.3 gql_dio_link: ^0.2.3 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../../links/gql_exec + gql_link: + path: ../../links/gql_link + gql_websocket_link: + path: ../../links/gql_websocket_link + gql_transform_link: + path: ../../links/gql_transform_link + gql_http_link: + path: ../../links/gql_http_link + gql_error_link: + path: ../../links/gql_error_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_example_http_auth_link: + path: ../gql_example_http_auth_link + gql_dio_link: + path: ../../links/gql_dio_link + gql_example_cli_github: + path: ../gql_example_cli_github + gql_example_cli: + path: ../gql_example_cli + gql_example_build: + path: ../gql_example_build + gql_dedupe_link: + path: ../../links/gql_dedupe_link + end_to_end_test: + path: ../../codegen/end_to_end_test diff --git a/examples/gql_example_flutter/pubspec.yaml b/examples/gql_example_flutter/pubspec.yaml index 67c2e247..2d2276e2 100644 --- a/examples/gql_example_flutter/pubspec.yaml +++ b/examples/gql_example_flutter/pubspec.yaml @@ -16,5 +16,42 @@ dev_dependencies: gql_build: ^0.7.0 flutter_test: sdk: flutter +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../../links/gql_exec + gql_link: + path: ../../links/gql_link + gql_websocket_link: + path: ../../links/gql_websocket_link + gql_transform_link: + path: ../../links/gql_transform_link + gql_http_link: + path: ../../links/gql_http_link + gql_error_link: + path: ../../links/gql_error_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_example_http_auth_link: + path: ../gql_example_http_auth_link + gql_dio_link: + path: ../../links/gql_dio_link + gql_example_dio_link: + path: ../gql_example_dio_link + gql_example_cli_github: + path: ../gql_example_cli_github + gql_example_cli: + path: ../gql_example_cli + gql_example_build: + path: ../gql_example_build + gql_dedupe_link: + path: ../../links/gql_dedupe_link + end_to_end_test: + path: ../../codegen/end_to_end_test flutter: uses-material-design: true diff --git a/examples/gql_example_http_auth_link/pubspec.yaml b/examples/gql_example_http_auth_link/pubspec.yaml index 366b56a6..5f159bd8 100644 --- a/examples/gql_example_http_auth_link/pubspec.yaml +++ b/examples/gql_example_http_auth_link/pubspec.yaml @@ -12,3 +12,38 @@ dependencies: dev_dependencies: gql_build: ^0.7.0 gql_pedantic: ^1.0.2 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../../links/gql_exec + gql_link: + path: ../../links/gql_link + gql_websocket_link: + path: ../../links/gql_websocket_link + gql_transform_link: + path: ../../links/gql_transform_link + gql_http_link: + path: ../../links/gql_http_link + gql_error_link: + path: ../../links/gql_error_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_dio_link: + path: ../../links/gql_dio_link + gql_example_dio_link: + path: ../gql_example_dio_link + gql_example_cli_github: + path: ../gql_example_cli_github + gql_example_cli: + path: ../gql_example_cli + gql_example_build: + path: ../gql_example_build + gql_dedupe_link: + path: ../../links/gql_dedupe_link + end_to_end_test: + path: ../../codegen/end_to_end_test diff --git a/gql/pubspec.yaml b/gql/pubspec.yaml index 0ba09aab..25e465f5 100644 --- a/gql/pubspec.yaml +++ b/gql/pubspec.yaml @@ -12,3 +12,38 @@ dependencies: dev_dependencies: gql_pedantic: ^1.0.2 test: ^1.16.2 +dependency_overrides: + gql_pedantic: + path: ../gql_pedantic + gql_exec: + path: ../links/gql_exec + gql_link: + path: ../links/gql_link + gql_websocket_link: + path: ../links/gql_websocket_link + gql_transform_link: + path: ../links/gql_transform_link + gql_http_link: + path: ../links/gql_http_link + gql_error_link: + path: ../links/gql_error_link + gql_code_builder: + path: ../codegen/gql_code_builder + gql_build: + path: ../codegen/gql_build + gql_example_http_auth_link: + path: ../examples/gql_example_http_auth_link + gql_dio_link: + path: ../links/gql_dio_link + gql_example_dio_link: + path: ../examples/gql_example_dio_link + gql_example_cli_github: + path: ../examples/gql_example_cli_github + gql_example_cli: + path: ../examples/gql_example_cli + gql_example_build: + path: ../examples/gql_example_build + gql_dedupe_link: + path: ../links/gql_dedupe_link + end_to_end_test: + path: ../codegen/end_to_end_test diff --git a/gql_pedantic/pubspec.yaml b/gql_pedantic/pubspec.yaml index 273b3751..46329e7b 100644 --- a/gql_pedantic/pubspec.yaml +++ b/gql_pedantic/pubspec.yaml @@ -4,3 +4,38 @@ description: Even more opinionated lint rules. repository: https://github.com/gql-dart/gql environment: sdk: '>=2.7.2 <3.0.0' +dependency_overrides: + gql: + path: ../gql + gql_exec: + path: ../links/gql_exec + gql_link: + path: ../links/gql_link + gql_websocket_link: + path: ../links/gql_websocket_link + gql_transform_link: + path: ../links/gql_transform_link + gql_http_link: + path: ../links/gql_http_link + gql_error_link: + path: ../links/gql_error_link + gql_code_builder: + path: ../codegen/gql_code_builder + gql_build: + path: ../codegen/gql_build + gql_example_http_auth_link: + path: ../examples/gql_example_http_auth_link + gql_dio_link: + path: ../links/gql_dio_link + gql_example_dio_link: + path: ../examples/gql_example_dio_link + gql_example_cli_github: + path: ../examples/gql_example_cli_github + gql_example_cli: + path: ../examples/gql_example_cli + gql_example_build: + path: ../examples/gql_example_build + gql_dedupe_link: + path: ../links/gql_dedupe_link + end_to_end_test: + path: ../codegen/end_to_end_test diff --git a/links/gql_dedupe_link/pubspec.yaml b/links/gql_dedupe_link/pubspec.yaml index 779d38e5..7e0d03f2 100644 --- a/links/gql_dedupe_link/pubspec.yaml +++ b/links/gql_dedupe_link/pubspec.yaml @@ -14,3 +14,38 @@ dev_dependencies: gql_pedantic: ^1.0.2 mockito: ^5.0.0-nullsafety.7 test: ^1.16.2 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../gql_exec + gql_link: + path: ../gql_link + gql_websocket_link: + path: ../gql_websocket_link + gql_transform_link: + path: ../gql_transform_link + gql_http_link: + path: ../gql_http_link + gql_error_link: + path: ../gql_error_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_example_http_auth_link: + path: ../../examples/gql_example_http_auth_link + gql_dio_link: + path: ../gql_dio_link + gql_example_dio_link: + path: ../../examples/gql_example_dio_link + gql_example_cli_github: + path: ../../examples/gql_example_cli_github + gql_example_cli: + path: ../../examples/gql_example_cli + gql_example_build: + path: ../../examples/gql_example_build + end_to_end_test: + path: ../../codegen/end_to_end_test diff --git a/links/gql_dio_link/pubspec.yaml b/links/gql_dio_link/pubspec.yaml index 8618929e..f42a6ce0 100644 --- a/links/gql_dio_link/pubspec.yaml +++ b/links/gql_dio_link/pubspec.yaml @@ -18,3 +18,38 @@ dev_dependencies: http_parser: ^4.0.0 mockito: ^5.3.0 test: ^1.14.3 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../gql_exec + gql_link: + path: ../gql_link + gql_websocket_link: + path: ../gql_websocket_link + gql_transform_link: + path: ../gql_transform_link + gql_http_link: + path: ../gql_http_link + gql_error_link: + path: ../gql_error_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_example_http_auth_link: + path: ../../examples/gql_example_http_auth_link + gql_example_dio_link: + path: ../../examples/gql_example_dio_link + gql_example_cli_github: + path: ../../examples/gql_example_cli_github + gql_example_cli: + path: ../../examples/gql_example_cli + gql_example_build: + path: ../../examples/gql_example_build + gql_dedupe_link: + path: ../gql_dedupe_link + end_to_end_test: + path: ../../codegen/end_to_end_test diff --git a/links/gql_error_link/pubspec.yaml b/links/gql_error_link/pubspec.yaml index 9eb27d5d..c198982e 100644 --- a/links/gql_error_link/pubspec.yaml +++ b/links/gql_error_link/pubspec.yaml @@ -14,3 +14,38 @@ dev_dependencies: gql_pedantic: ^1.0.2 mockito: ^5.0.0-nullsafety.7 test: ^1.16.2 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../gql_exec + gql_link: + path: ../gql_link + gql_websocket_link: + path: ../gql_websocket_link + gql_transform_link: + path: ../gql_transform_link + gql_http_link: + path: ../gql_http_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_example_http_auth_link: + path: ../../examples/gql_example_http_auth_link + gql_dio_link: + path: ../gql_dio_link + gql_example_dio_link: + path: ../../examples/gql_example_dio_link + gql_example_cli_github: + path: ../../examples/gql_example_cli_github + gql_example_cli: + path: ../../examples/gql_example_cli + gql_example_build: + path: ../../examples/gql_example_build + gql_dedupe_link: + path: ../gql_dedupe_link + end_to_end_test: + path: ../../codegen/end_to_end_test diff --git a/links/gql_exec/lib/src/value.dart b/links/gql_exec/lib/src/value.dart new file mode 100644 index 00000000..0ab0b96a --- /dev/null +++ b/links/gql_exec/lib/src/value.dart @@ -0,0 +1,18 @@ +class Value { + final T? _value; + + T? get value => _value; + + /// Create a (present) value by wrapping the [value] provided. + const Value(T? value) : _value = value; + + const Value.ofNull() : _value = null; + + @override + bool operator ==(Object other) => + identical(this, other) || + other is Value && runtimeType == other.runtimeType && _value == other._value; + + @override + int get hashCode => _value.hashCode; +} diff --git a/links/gql_exec/lib/value.dart b/links/gql_exec/lib/value.dart new file mode 100644 index 00000000..4d086bbb --- /dev/null +++ b/links/gql_exec/lib/value.dart @@ -0,0 +1 @@ +export "package:gql_exec/src/value.dart"; diff --git a/links/gql_exec/pubspec.yaml b/links/gql_exec/pubspec.yaml index a9ec3dd0..efb82a39 100644 --- a/links/gql_exec/pubspec.yaml +++ b/links/gql_exec/pubspec.yaml @@ -11,3 +11,38 @@ dependencies: dev_dependencies: gql_pedantic: ^1.0.2 test: ^1.16.2 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_link: + path: ../gql_link + gql_websocket_link: + path: ../gql_websocket_link + gql_transform_link: + path: ../gql_transform_link + gql_http_link: + path: ../gql_http_link + gql_error_link: + path: ../gql_error_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_example_http_auth_link: + path: ../../examples/gql_example_http_auth_link + gql_dio_link: + path: ../gql_dio_link + gql_example_dio_link: + path: ../../examples/gql_example_dio_link + gql_example_cli_github: + path: ../../examples/gql_example_cli_github + gql_example_cli: + path: ../../examples/gql_example_cli + gql_example_build: + path: ../../examples/gql_example_build + gql_dedupe_link: + path: ../gql_dedupe_link + end_to_end_test: + path: ../../codegen/end_to_end_test diff --git a/links/gql_http_link/lib/src/link.dart b/links/gql_http_link/lib/src/link.dart index 167aacdb..757bd582 100644 --- a/links/gql_http_link/lib/src/link.dart +++ b/links/gql_http_link/lib/src/link.dart @@ -53,6 +53,8 @@ class HttpLink extends Link { http.Client? _httpClient; + final bool followRedirects; + /// Construct the Link /// /// You can pass a [httpClient] to extend to customize the network request. @@ -64,6 +66,7 @@ class HttpLink extends Link { this.serializer = const RequestSerializer(), this.parser = const ResponseParser(), this.httpResponseDecoder = _defaultHttpResponseDecoder, + this.followRedirects = false, }) : uri = Uri.parse(uri) { _httpClient = httpClient ?? http.Client(); } @@ -188,6 +191,7 @@ class HttpLink extends Link { } return http.Request("POST", uri) ..body = httpBody + ..followRedirects = followRedirects ..headers.addAll(headers); } diff --git a/links/gql_http_link/pubspec.yaml b/links/gql_http_link/pubspec.yaml index 732ce577..cf9cbc65 100644 --- a/links/gql_http_link/pubspec.yaml +++ b/links/gql_http_link/pubspec.yaml @@ -17,3 +17,38 @@ dev_dependencies: gql_pedantic: ^1.0.2 mockito: ^5.3.0 test: ^1.16.2 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../gql_exec + gql_link: + path: ../gql_link + gql_websocket_link: + path: ../gql_websocket_link + gql_transform_link: + path: ../gql_transform_link + gql_error_link: + path: ../gql_error_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_example_http_auth_link: + path: ../../examples/gql_example_http_auth_link + gql_dio_link: + path: ../gql_dio_link + gql_example_dio_link: + path: ../../examples/gql_example_dio_link + gql_example_cli_github: + path: ../../examples/gql_example_cli_github + gql_example_cli: + path: ../../examples/gql_example_cli + gql_example_build: + path: ../../examples/gql_example_build + gql_dedupe_link: + path: ../gql_dedupe_link + end_to_end_test: + path: ../../codegen/end_to_end_test diff --git a/links/gql_link/pubspec.yaml b/links/gql_link/pubspec.yaml index 2ff02eef..601748fc 100644 --- a/links/gql_link/pubspec.yaml +++ b/links/gql_link/pubspec.yaml @@ -12,3 +12,38 @@ dev_dependencies: gql_pedantic: ^1.0.2 mockito: ^5.0.16 test: ^1.16.2 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../gql_exec + gql_websocket_link: + path: ../gql_websocket_link + gql_transform_link: + path: ../gql_transform_link + gql_http_link: + path: ../gql_http_link + gql_error_link: + path: ../gql_error_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_example_http_auth_link: + path: ../../examples/gql_example_http_auth_link + gql_dio_link: + path: ../gql_dio_link + gql_example_dio_link: + path: ../../examples/gql_example_dio_link + gql_example_cli_github: + path: ../../examples/gql_example_cli_github + gql_example_cli: + path: ../../examples/gql_example_cli + gql_example_build: + path: ../../examples/gql_example_build + gql_dedupe_link: + path: ../gql_dedupe_link + end_to_end_test: + path: ../../codegen/end_to_end_test diff --git a/links/gql_transform_link/pubspec.yaml b/links/gql_transform_link/pubspec.yaml index b958dd0c..9836b5be 100644 --- a/links/gql_transform_link/pubspec.yaml +++ b/links/gql_transform_link/pubspec.yaml @@ -12,3 +12,38 @@ dev_dependencies: gql_pedantic: ^1.0.2 mockito: ^5.0.0-nullsafety.7 test: ^1.16.2 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../gql_exec + gql_link: + path: ../gql_link + gql_websocket_link: + path: ../gql_websocket_link + gql_http_link: + path: ../gql_http_link + gql_error_link: + path: ../gql_error_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_example_http_auth_link: + path: ../../examples/gql_example_http_auth_link + gql_dio_link: + path: ../gql_dio_link + gql_example_dio_link: + path: ../../examples/gql_example_dio_link + gql_example_cli_github: + path: ../../examples/gql_example_cli_github + gql_example_cli: + path: ../../examples/gql_example_cli + gql_example_build: + path: ../../examples/gql_example_build + gql_dedupe_link: + path: ../gql_dedupe_link + end_to_end_test: + path: ../../codegen/end_to_end_test diff --git a/links/gql_websocket_link/pubspec.yaml b/links/gql_websocket_link/pubspec.yaml index dc1cc08e..365461fa 100644 --- a/links/gql_websocket_link/pubspec.yaml +++ b/links/gql_websocket_link/pubspec.yaml @@ -16,3 +16,38 @@ dev_dependencies: gql_pedantic: ^1.0.2 mockito: ^5.0.0 test: ^1.16.6 +dependency_overrides: + gql_pedantic: + path: ../../gql_pedantic + gql: + path: ../../gql + gql_exec: + path: ../gql_exec + gql_link: + path: ../gql_link + gql_transform_link: + path: ../gql_transform_link + gql_http_link: + path: ../gql_http_link + gql_error_link: + path: ../gql_error_link + gql_code_builder: + path: ../../codegen/gql_code_builder + gql_build: + path: ../../codegen/gql_build + gql_example_http_auth_link: + path: ../../examples/gql_example_http_auth_link + gql_dio_link: + path: ../gql_dio_link + gql_example_dio_link: + path: ../../examples/gql_example_dio_link + gql_example_cli_github: + path: ../../examples/gql_example_cli_github + gql_example_cli: + path: ../../examples/gql_example_cli + gql_example_build: + path: ../../examples/gql_example_build + gql_dedupe_link: + path: ../gql_dedupe_link + end_to_end_test: + path: ../../codegen/end_to_end_test From e0b1ae432fe19706ebf67a98246765ed8c19de36 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 29 Jan 2023 19:18:44 +0100 Subject: [PATCH 02/10] pubspec clean --- codegen/end_to_end_test/pubspec.yaml | 35 ------------------ codegen/gql_build/pubspec.yaml | 35 ------------------ codegen/gql_code_builder/pubspec.yaml | 35 ------------------ examples/gql_example_build/pubspec.yaml | 35 ------------------ examples/gql_example_cli/pubspec.yaml | 35 ------------------ examples/gql_example_cli_github/pubspec.yaml | 35 ------------------ examples/gql_example_dio_link/pubspec.yaml | 35 ------------------ examples/gql_example_flutter/pubspec.yaml | 37 ------------------- .../gql_example_http_auth_link/pubspec.yaml | 35 ------------------ gql/pubspec.yaml | 35 ------------------ gql_pedantic/pubspec.yaml | 35 ------------------ links/gql_dedupe_link/pubspec.yaml | 35 ------------------ links/gql_dio_link/pubspec.yaml | 35 ------------------ links/gql_error_link/pubspec.yaml | 35 ------------------ links/gql_exec/pubspec.yaml | 35 ------------------ links/gql_http_link/pubspec.yaml | 35 ------------------ links/gql_link/pubspec.yaml | 35 ------------------ links/gql_transform_link/pubspec.yaml | 35 ------------------ links/gql_websocket_link/pubspec.yaml | 35 ------------------ 19 files changed, 667 deletions(-) diff --git a/codegen/end_to_end_test/pubspec.yaml b/codegen/end_to_end_test/pubspec.yaml index c91a20df..a1fb6f80 100644 --- a/codegen/end_to_end_test/pubspec.yaml +++ b/codegen/end_to_end_test/pubspec.yaml @@ -15,38 +15,3 @@ dev_dependencies: build: ^2.0.0 build_runner: ^2.0.0 test: ^1.16.8 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../../links/gql_exec - gql_link: - path: ../../links/gql_link - gql_websocket_link: - path: ../../links/gql_websocket_link - gql_transform_link: - path: ../../links/gql_transform_link - gql_http_link: - path: ../../links/gql_http_link - gql_error_link: - path: ../../links/gql_error_link - gql_code_builder: - path: ../gql_code_builder - gql_build: - path: ../gql_build - gql_example_http_auth_link: - path: ../../examples/gql_example_http_auth_link - gql_dio_link: - path: ../../links/gql_dio_link - gql_example_dio_link: - path: ../../examples/gql_example_dio_link - gql_example_cli_github: - path: ../../examples/gql_example_cli_github - gql_example_cli: - path: ../../examples/gql_example_cli - gql_example_build: - path: ../../examples/gql_example_build - gql_dedupe_link: - path: ../../links/gql_dedupe_link diff --git a/codegen/gql_build/pubspec.yaml b/codegen/gql_build/pubspec.yaml index 3012d6cf..17582bd3 100644 --- a/codegen/gql_build/pubspec.yaml +++ b/codegen/gql_build/pubspec.yaml @@ -20,38 +20,3 @@ dependencies: dev_dependencies: build_test: ^2.0.0 gql_pedantic: ^1.0.2 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../../links/gql_exec - gql_link: - path: ../../links/gql_link - gql_websocket_link: - path: ../../links/gql_websocket_link - gql_transform_link: - path: ../../links/gql_transform_link - gql_http_link: - path: ../../links/gql_http_link - gql_error_link: - path: ../../links/gql_error_link - gql_code_builder: - path: ../gql_code_builder - gql_example_http_auth_link: - path: ../../examples/gql_example_http_auth_link - gql_dio_link: - path: ../../links/gql_dio_link - gql_example_dio_link: - path: ../../examples/gql_example_dio_link - gql_example_cli_github: - path: ../../examples/gql_example_cli_github - gql_example_cli: - path: ../../examples/gql_example_cli - gql_example_build: - path: ../../examples/gql_example_build - gql_dedupe_link: - path: ../../links/gql_dedupe_link - end_to_end_test: - path: ../end_to_end_test diff --git a/codegen/gql_code_builder/pubspec.yaml b/codegen/gql_code_builder/pubspec.yaml index 1150c2d9..4f7e855a 100644 --- a/codegen/gql_code_builder/pubspec.yaml +++ b/codegen/gql_code_builder/pubspec.yaml @@ -17,38 +17,3 @@ dev_dependencies: build_runner: ^2.1.0 gql_pedantic: ^1.0.2 test: ^1.16.8 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../../links/gql_exec - gql_link: - path: ../../links/gql_link - gql_websocket_link: - path: ../../links/gql_websocket_link - gql_transform_link: - path: ../../links/gql_transform_link - gql_http_link: - path: ../../links/gql_http_link - gql_error_link: - path: ../../links/gql_error_link - gql_build: - path: ../gql_build - gql_example_http_auth_link: - path: ../../examples/gql_example_http_auth_link - gql_dio_link: - path: ../../links/gql_dio_link - gql_example_dio_link: - path: ../../examples/gql_example_dio_link - gql_example_cli_github: - path: ../../examples/gql_example_cli_github - gql_example_cli: - path: ../../examples/gql_example_cli - gql_example_build: - path: ../../examples/gql_example_build - gql_dedupe_link: - path: ../../links/gql_dedupe_link - end_to_end_test: - path: ../end_to_end_test diff --git a/examples/gql_example_build/pubspec.yaml b/examples/gql_example_build/pubspec.yaml index f0e24baf..54cac320 100644 --- a/examples/gql_example_build/pubspec.yaml +++ b/examples/gql_example_build/pubspec.yaml @@ -6,38 +6,3 @@ dev_dependencies: gql_build: ^0.7.0 gql_pedantic: ^1.0.2 test: ^1.0.0 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../../links/gql_exec - gql_link: - path: ../../links/gql_link - gql_websocket_link: - path: ../../links/gql_websocket_link - gql_transform_link: - path: ../../links/gql_transform_link - gql_http_link: - path: ../../links/gql_http_link - gql_error_link: - path: ../../links/gql_error_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_example_http_auth_link: - path: ../gql_example_http_auth_link - gql_dio_link: - path: ../../links/gql_dio_link - gql_example_dio_link: - path: ../gql_example_dio_link - gql_example_cli_github: - path: ../gql_example_cli_github - gql_example_cli: - path: ../gql_example_cli - gql_dedupe_link: - path: ../../links/gql_dedupe_link - end_to_end_test: - path: ../../codegen/end_to_end_test diff --git a/examples/gql_example_cli/pubspec.yaml b/examples/gql_example_cli/pubspec.yaml index 26c96d5d..64075f49 100644 --- a/examples/gql_example_cli/pubspec.yaml +++ b/examples/gql_example_cli/pubspec.yaml @@ -11,38 +11,3 @@ dev_dependencies: build_runner: ^2.0.0 gql_build: ^0.7.0 gql_pedantic: ^1.0.2 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../../links/gql_exec - gql_link: - path: ../../links/gql_link - gql_websocket_link: - path: ../../links/gql_websocket_link - gql_transform_link: - path: ../../links/gql_transform_link - gql_http_link: - path: ../../links/gql_http_link - gql_error_link: - path: ../../links/gql_error_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_example_http_auth_link: - path: ../gql_example_http_auth_link - gql_dio_link: - path: ../../links/gql_dio_link - gql_example_dio_link: - path: ../gql_example_dio_link - gql_example_cli_github: - path: ../gql_example_cli_github - gql_example_build: - path: ../gql_example_build - gql_dedupe_link: - path: ../../links/gql_dedupe_link - end_to_end_test: - path: ../../codegen/end_to_end_test diff --git a/examples/gql_example_cli_github/pubspec.yaml b/examples/gql_example_cli_github/pubspec.yaml index 7d0449d4..c2223123 100644 --- a/examples/gql_example_cli_github/pubspec.yaml +++ b/examples/gql_example_cli_github/pubspec.yaml @@ -12,38 +12,3 @@ dev_dependencies: build_runner: ^2.0.0 gql_build: ^0.7.0 gql_pedantic: ^1.0.2 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../../links/gql_exec - gql_link: - path: ../../links/gql_link - gql_websocket_link: - path: ../../links/gql_websocket_link - gql_transform_link: - path: ../../links/gql_transform_link - gql_http_link: - path: ../../links/gql_http_link - gql_error_link: - path: ../../links/gql_error_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_example_http_auth_link: - path: ../gql_example_http_auth_link - gql_dio_link: - path: ../../links/gql_dio_link - gql_example_dio_link: - path: ../gql_example_dio_link - gql_example_cli: - path: ../gql_example_cli - gql_example_build: - path: ../gql_example_build - gql_dedupe_link: - path: ../../links/gql_dedupe_link - end_to_end_test: - path: ../../codegen/end_to_end_test diff --git a/examples/gql_example_dio_link/pubspec.yaml b/examples/gql_example_dio_link/pubspec.yaml index b3da1bc5..eb1dfbea 100644 --- a/examples/gql_example_dio_link/pubspec.yaml +++ b/examples/gql_example_dio_link/pubspec.yaml @@ -8,38 +8,3 @@ dependencies: gql_link: ^0.5.0 gql_exec: ^0.4.3 gql_dio_link: ^0.2.3 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../../links/gql_exec - gql_link: - path: ../../links/gql_link - gql_websocket_link: - path: ../../links/gql_websocket_link - gql_transform_link: - path: ../../links/gql_transform_link - gql_http_link: - path: ../../links/gql_http_link - gql_error_link: - path: ../../links/gql_error_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_example_http_auth_link: - path: ../gql_example_http_auth_link - gql_dio_link: - path: ../../links/gql_dio_link - gql_example_cli_github: - path: ../gql_example_cli_github - gql_example_cli: - path: ../gql_example_cli - gql_example_build: - path: ../gql_example_build - gql_dedupe_link: - path: ../../links/gql_dedupe_link - end_to_end_test: - path: ../../codegen/end_to_end_test diff --git a/examples/gql_example_flutter/pubspec.yaml b/examples/gql_example_flutter/pubspec.yaml index 2d2276e2..67c2e247 100644 --- a/examples/gql_example_flutter/pubspec.yaml +++ b/examples/gql_example_flutter/pubspec.yaml @@ -16,42 +16,5 @@ dev_dependencies: gql_build: ^0.7.0 flutter_test: sdk: flutter -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../../links/gql_exec - gql_link: - path: ../../links/gql_link - gql_websocket_link: - path: ../../links/gql_websocket_link - gql_transform_link: - path: ../../links/gql_transform_link - gql_http_link: - path: ../../links/gql_http_link - gql_error_link: - path: ../../links/gql_error_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_example_http_auth_link: - path: ../gql_example_http_auth_link - gql_dio_link: - path: ../../links/gql_dio_link - gql_example_dio_link: - path: ../gql_example_dio_link - gql_example_cli_github: - path: ../gql_example_cli_github - gql_example_cli: - path: ../gql_example_cli - gql_example_build: - path: ../gql_example_build - gql_dedupe_link: - path: ../../links/gql_dedupe_link - end_to_end_test: - path: ../../codegen/end_to_end_test flutter: uses-material-design: true diff --git a/examples/gql_example_http_auth_link/pubspec.yaml b/examples/gql_example_http_auth_link/pubspec.yaml index 5f159bd8..366b56a6 100644 --- a/examples/gql_example_http_auth_link/pubspec.yaml +++ b/examples/gql_example_http_auth_link/pubspec.yaml @@ -12,38 +12,3 @@ dependencies: dev_dependencies: gql_build: ^0.7.0 gql_pedantic: ^1.0.2 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../../links/gql_exec - gql_link: - path: ../../links/gql_link - gql_websocket_link: - path: ../../links/gql_websocket_link - gql_transform_link: - path: ../../links/gql_transform_link - gql_http_link: - path: ../../links/gql_http_link - gql_error_link: - path: ../../links/gql_error_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_dio_link: - path: ../../links/gql_dio_link - gql_example_dio_link: - path: ../gql_example_dio_link - gql_example_cli_github: - path: ../gql_example_cli_github - gql_example_cli: - path: ../gql_example_cli - gql_example_build: - path: ../gql_example_build - gql_dedupe_link: - path: ../../links/gql_dedupe_link - end_to_end_test: - path: ../../codegen/end_to_end_test diff --git a/gql/pubspec.yaml b/gql/pubspec.yaml index 25e465f5..0ba09aab 100644 --- a/gql/pubspec.yaml +++ b/gql/pubspec.yaml @@ -12,38 +12,3 @@ dependencies: dev_dependencies: gql_pedantic: ^1.0.2 test: ^1.16.2 -dependency_overrides: - gql_pedantic: - path: ../gql_pedantic - gql_exec: - path: ../links/gql_exec - gql_link: - path: ../links/gql_link - gql_websocket_link: - path: ../links/gql_websocket_link - gql_transform_link: - path: ../links/gql_transform_link - gql_http_link: - path: ../links/gql_http_link - gql_error_link: - path: ../links/gql_error_link - gql_code_builder: - path: ../codegen/gql_code_builder - gql_build: - path: ../codegen/gql_build - gql_example_http_auth_link: - path: ../examples/gql_example_http_auth_link - gql_dio_link: - path: ../links/gql_dio_link - gql_example_dio_link: - path: ../examples/gql_example_dio_link - gql_example_cli_github: - path: ../examples/gql_example_cli_github - gql_example_cli: - path: ../examples/gql_example_cli - gql_example_build: - path: ../examples/gql_example_build - gql_dedupe_link: - path: ../links/gql_dedupe_link - end_to_end_test: - path: ../codegen/end_to_end_test diff --git a/gql_pedantic/pubspec.yaml b/gql_pedantic/pubspec.yaml index 46329e7b..273b3751 100644 --- a/gql_pedantic/pubspec.yaml +++ b/gql_pedantic/pubspec.yaml @@ -4,38 +4,3 @@ description: Even more opinionated lint rules. repository: https://github.com/gql-dart/gql environment: sdk: '>=2.7.2 <3.0.0' -dependency_overrides: - gql: - path: ../gql - gql_exec: - path: ../links/gql_exec - gql_link: - path: ../links/gql_link - gql_websocket_link: - path: ../links/gql_websocket_link - gql_transform_link: - path: ../links/gql_transform_link - gql_http_link: - path: ../links/gql_http_link - gql_error_link: - path: ../links/gql_error_link - gql_code_builder: - path: ../codegen/gql_code_builder - gql_build: - path: ../codegen/gql_build - gql_example_http_auth_link: - path: ../examples/gql_example_http_auth_link - gql_dio_link: - path: ../links/gql_dio_link - gql_example_dio_link: - path: ../examples/gql_example_dio_link - gql_example_cli_github: - path: ../examples/gql_example_cli_github - gql_example_cli: - path: ../examples/gql_example_cli - gql_example_build: - path: ../examples/gql_example_build - gql_dedupe_link: - path: ../links/gql_dedupe_link - end_to_end_test: - path: ../codegen/end_to_end_test diff --git a/links/gql_dedupe_link/pubspec.yaml b/links/gql_dedupe_link/pubspec.yaml index 7e0d03f2..779d38e5 100644 --- a/links/gql_dedupe_link/pubspec.yaml +++ b/links/gql_dedupe_link/pubspec.yaml @@ -14,38 +14,3 @@ dev_dependencies: gql_pedantic: ^1.0.2 mockito: ^5.0.0-nullsafety.7 test: ^1.16.2 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../gql_exec - gql_link: - path: ../gql_link - gql_websocket_link: - path: ../gql_websocket_link - gql_transform_link: - path: ../gql_transform_link - gql_http_link: - path: ../gql_http_link - gql_error_link: - path: ../gql_error_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_example_http_auth_link: - path: ../../examples/gql_example_http_auth_link - gql_dio_link: - path: ../gql_dio_link - gql_example_dio_link: - path: ../../examples/gql_example_dio_link - gql_example_cli_github: - path: ../../examples/gql_example_cli_github - gql_example_cli: - path: ../../examples/gql_example_cli - gql_example_build: - path: ../../examples/gql_example_build - end_to_end_test: - path: ../../codegen/end_to_end_test diff --git a/links/gql_dio_link/pubspec.yaml b/links/gql_dio_link/pubspec.yaml index f42a6ce0..8618929e 100644 --- a/links/gql_dio_link/pubspec.yaml +++ b/links/gql_dio_link/pubspec.yaml @@ -18,38 +18,3 @@ dev_dependencies: http_parser: ^4.0.0 mockito: ^5.3.0 test: ^1.14.3 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../gql_exec - gql_link: - path: ../gql_link - gql_websocket_link: - path: ../gql_websocket_link - gql_transform_link: - path: ../gql_transform_link - gql_http_link: - path: ../gql_http_link - gql_error_link: - path: ../gql_error_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_example_http_auth_link: - path: ../../examples/gql_example_http_auth_link - gql_example_dio_link: - path: ../../examples/gql_example_dio_link - gql_example_cli_github: - path: ../../examples/gql_example_cli_github - gql_example_cli: - path: ../../examples/gql_example_cli - gql_example_build: - path: ../../examples/gql_example_build - gql_dedupe_link: - path: ../gql_dedupe_link - end_to_end_test: - path: ../../codegen/end_to_end_test diff --git a/links/gql_error_link/pubspec.yaml b/links/gql_error_link/pubspec.yaml index c198982e..9eb27d5d 100644 --- a/links/gql_error_link/pubspec.yaml +++ b/links/gql_error_link/pubspec.yaml @@ -14,38 +14,3 @@ dev_dependencies: gql_pedantic: ^1.0.2 mockito: ^5.0.0-nullsafety.7 test: ^1.16.2 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../gql_exec - gql_link: - path: ../gql_link - gql_websocket_link: - path: ../gql_websocket_link - gql_transform_link: - path: ../gql_transform_link - gql_http_link: - path: ../gql_http_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_example_http_auth_link: - path: ../../examples/gql_example_http_auth_link - gql_dio_link: - path: ../gql_dio_link - gql_example_dio_link: - path: ../../examples/gql_example_dio_link - gql_example_cli_github: - path: ../../examples/gql_example_cli_github - gql_example_cli: - path: ../../examples/gql_example_cli - gql_example_build: - path: ../../examples/gql_example_build - gql_dedupe_link: - path: ../gql_dedupe_link - end_to_end_test: - path: ../../codegen/end_to_end_test diff --git a/links/gql_exec/pubspec.yaml b/links/gql_exec/pubspec.yaml index efb82a39..a9ec3dd0 100644 --- a/links/gql_exec/pubspec.yaml +++ b/links/gql_exec/pubspec.yaml @@ -11,38 +11,3 @@ dependencies: dev_dependencies: gql_pedantic: ^1.0.2 test: ^1.16.2 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_link: - path: ../gql_link - gql_websocket_link: - path: ../gql_websocket_link - gql_transform_link: - path: ../gql_transform_link - gql_http_link: - path: ../gql_http_link - gql_error_link: - path: ../gql_error_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_example_http_auth_link: - path: ../../examples/gql_example_http_auth_link - gql_dio_link: - path: ../gql_dio_link - gql_example_dio_link: - path: ../../examples/gql_example_dio_link - gql_example_cli_github: - path: ../../examples/gql_example_cli_github - gql_example_cli: - path: ../../examples/gql_example_cli - gql_example_build: - path: ../../examples/gql_example_build - gql_dedupe_link: - path: ../gql_dedupe_link - end_to_end_test: - path: ../../codegen/end_to_end_test diff --git a/links/gql_http_link/pubspec.yaml b/links/gql_http_link/pubspec.yaml index cf9cbc65..732ce577 100644 --- a/links/gql_http_link/pubspec.yaml +++ b/links/gql_http_link/pubspec.yaml @@ -17,38 +17,3 @@ dev_dependencies: gql_pedantic: ^1.0.2 mockito: ^5.3.0 test: ^1.16.2 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../gql_exec - gql_link: - path: ../gql_link - gql_websocket_link: - path: ../gql_websocket_link - gql_transform_link: - path: ../gql_transform_link - gql_error_link: - path: ../gql_error_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_example_http_auth_link: - path: ../../examples/gql_example_http_auth_link - gql_dio_link: - path: ../gql_dio_link - gql_example_dio_link: - path: ../../examples/gql_example_dio_link - gql_example_cli_github: - path: ../../examples/gql_example_cli_github - gql_example_cli: - path: ../../examples/gql_example_cli - gql_example_build: - path: ../../examples/gql_example_build - gql_dedupe_link: - path: ../gql_dedupe_link - end_to_end_test: - path: ../../codegen/end_to_end_test diff --git a/links/gql_link/pubspec.yaml b/links/gql_link/pubspec.yaml index 601748fc..2ff02eef 100644 --- a/links/gql_link/pubspec.yaml +++ b/links/gql_link/pubspec.yaml @@ -12,38 +12,3 @@ dev_dependencies: gql_pedantic: ^1.0.2 mockito: ^5.0.16 test: ^1.16.2 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../gql_exec - gql_websocket_link: - path: ../gql_websocket_link - gql_transform_link: - path: ../gql_transform_link - gql_http_link: - path: ../gql_http_link - gql_error_link: - path: ../gql_error_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_example_http_auth_link: - path: ../../examples/gql_example_http_auth_link - gql_dio_link: - path: ../gql_dio_link - gql_example_dio_link: - path: ../../examples/gql_example_dio_link - gql_example_cli_github: - path: ../../examples/gql_example_cli_github - gql_example_cli: - path: ../../examples/gql_example_cli - gql_example_build: - path: ../../examples/gql_example_build - gql_dedupe_link: - path: ../gql_dedupe_link - end_to_end_test: - path: ../../codegen/end_to_end_test diff --git a/links/gql_transform_link/pubspec.yaml b/links/gql_transform_link/pubspec.yaml index 9836b5be..b958dd0c 100644 --- a/links/gql_transform_link/pubspec.yaml +++ b/links/gql_transform_link/pubspec.yaml @@ -12,38 +12,3 @@ dev_dependencies: gql_pedantic: ^1.0.2 mockito: ^5.0.0-nullsafety.7 test: ^1.16.2 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../gql_exec - gql_link: - path: ../gql_link - gql_websocket_link: - path: ../gql_websocket_link - gql_http_link: - path: ../gql_http_link - gql_error_link: - path: ../gql_error_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_example_http_auth_link: - path: ../../examples/gql_example_http_auth_link - gql_dio_link: - path: ../gql_dio_link - gql_example_dio_link: - path: ../../examples/gql_example_dio_link - gql_example_cli_github: - path: ../../examples/gql_example_cli_github - gql_example_cli: - path: ../../examples/gql_example_cli - gql_example_build: - path: ../../examples/gql_example_build - gql_dedupe_link: - path: ../gql_dedupe_link - end_to_end_test: - path: ../../codegen/end_to_end_test diff --git a/links/gql_websocket_link/pubspec.yaml b/links/gql_websocket_link/pubspec.yaml index 365461fa..dc1cc08e 100644 --- a/links/gql_websocket_link/pubspec.yaml +++ b/links/gql_websocket_link/pubspec.yaml @@ -16,38 +16,3 @@ dev_dependencies: gql_pedantic: ^1.0.2 mockito: ^5.0.0 test: ^1.16.6 -dependency_overrides: - gql_pedantic: - path: ../../gql_pedantic - gql: - path: ../../gql - gql_exec: - path: ../gql_exec - gql_link: - path: ../gql_link - gql_transform_link: - path: ../gql_transform_link - gql_http_link: - path: ../gql_http_link - gql_error_link: - path: ../gql_error_link - gql_code_builder: - path: ../../codegen/gql_code_builder - gql_build: - path: ../../codegen/gql_build - gql_example_http_auth_link: - path: ../../examples/gql_example_http_auth_link - gql_dio_link: - path: ../gql_dio_link - gql_example_dio_link: - path: ../../examples/gql_example_dio_link - gql_example_cli_github: - path: ../../examples/gql_example_cli_github - gql_example_cli: - path: ../../examples/gql_example_cli - gql_example_build: - path: ../../examples/gql_example_build - gql_dedupe_link: - path: ../gql_dedupe_link - end_to_end_test: - path: ../../codegen/end_to_end_test From a613a17686d6607c92943b6f76e3e99623ccafbf Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 29 Jan 2023 19:19:01 +0100 Subject: [PATCH 03/10] format --- .../test/schema/scalars_test.dart | 13 +++- codegen/gql_build/lib/src/schema_builder.dart | 18 +++-- .../gql_build/lib/src/serializer_builder.dart | 22 ++++-- codegen/gql_build/lib/src/var_builder.dart | 10 ++- codegen/gql_code_builder/lib/schema.dart | 3 +- .../gql_code_builder/lib/src/built_class.dart | 8 +- codegen/gql_code_builder/lib/src/common.dart | 6 +- codegen/gql_code_builder/lib/src/schema.dart | 12 +-- .../lib/src/schema/input.dart | 4 +- codegen/gql_code_builder/lib/var.dart | 76 +++++++++++-------- .../src/operation/definitions/selections.dart | 1 - links/gql_exec/lib/src/value.dart | 4 +- links/gql_link/lib/src/link.dart | 1 - 13 files changed, 109 insertions(+), 69 deletions(-) diff --git a/codegen/end_to_end_test/test/schema/scalars_test.dart b/codegen/end_to_end_test/test/schema/scalars_test.dart index 6eab24ad..bf7e70f7 100644 --- a/codegen/end_to_end_test/test/schema/scalars_test.dart +++ b/codegen/end_to_end_test/test/schema/scalars_test.dart @@ -50,8 +50,10 @@ void main() { final scalar = GISODate(isoString); test('correctly serializes and deserializes', () { - expect(serializers.deserializeWith(GISODate.serializer, isoString), equals(scalar)); - expect(serializers.serializeWith(GISODate.serializer, scalar), equals(isoString)); + expect(serializers.deserializeWith(GISODate.serializer, isoString), + equals(scalar)); + expect(serializers.serializeWith(GISODate.serializer, scalar), + equals(isoString)); }); }); @@ -102,8 +104,11 @@ void main() { final data = GReviewWithDateData( (b) => b ..createReview.stars = 1 - ..createReview.seenOn.add(DateTime.fromMillisecondsSinceEpoch(1591892597000)) - ..createReview.createdAt = DateTime.fromMillisecondsSinceEpoch(1591892597000), + ..createReview + .seenOn + .add(DateTime.fromMillisecondsSinceEpoch(1591892597000)) + ..createReview.createdAt = + DateTime.fromMillisecondsSinceEpoch(1591892597000), ); test('correctly overrides scalars in data types', () { diff --git a/codegen/gql_build/lib/src/schema_builder.dart b/codegen/gql_build/lib/src/schema_builder.dart index c7e2cfca..d85096f9 100644 --- a/codegen/gql_build/lib/src/schema_builder.dart +++ b/codegen/gql_build/lib/src/schema_builder.dart @@ -15,7 +15,8 @@ class SchemaBuilder implements Builder { final EnumFallbackConfig enumFallbackConfig; final bool generatePossibleTypesMap; - SchemaBuilder(this.typeOverrides, this.enumFallbackConfig, this.generatePossibleTypesMap); + SchemaBuilder(this.typeOverrides, this.enumFallbackConfig, + this.generatePossibleTypesMap); @override Map> get buildExtensions => { @@ -26,10 +27,13 @@ class SchemaBuilder implements Builder { FutureOr build(BuildStep buildStep) async { final doc = await readDocument(buildStep); - final generatedPartUrl = - buildStep.inputId.changeExtension(generatedFileExtension(schemaExtension)).uri.path; + final generatedPartUrl = buildStep.inputId + .changeExtension(generatedFileExtension(schemaExtension)) + .uri + .path; - final schemaUrl = outputAssetId(buildStep.inputId, schemaExtension).uri.toString(); + final schemaUrl = + outputAssetId(buildStep.inputId, schemaExtension).uri.toString(); final allocator = GqlAllocator( buildStep.inputId.uri.toString(), outputAssetId(buildStep.inputId, schemaExtension).uri.toString(), @@ -38,8 +42,10 @@ class SchemaBuilder implements Builder { final library = buildSchemaLibrary( doc, basename(generatedPartUrl), typeOverrides, enumFallbackConfig, - generatePossibleTypesMap: generatePossibleTypesMap, allocator: allocator); + generatePossibleTypesMap: generatePossibleTypesMap, + allocator: allocator); - return writeDocument(library, buildStep, schemaExtension, schemaUrl, allocator); + return writeDocument( + library, buildStep, schemaExtension, schemaUrl, allocator); } } diff --git a/codegen/gql_build/lib/src/serializer_builder.dart b/codegen/gql_build/lib/src/serializer_builder.dart index b9d49762..16d60280 100644 --- a/codegen/gql_build/lib/src/serializer_builder.dart +++ b/codegen/gql_build/lib/src/serializer_builder.dart @@ -29,9 +29,10 @@ class SerializerBuilder implements Builder { static final _generatedFiles = Glob("lib/**.gql.dart"); // create a path for the serializers output in same directory as schema - List get pathSegments => outputAssetId(schemaId, serializerExtension).pathSegments - ..removeLast() - ..add("serializers.gql.dart"); + List get pathSegments => + outputAssetId(schemaId, serializerExtension).pathSegments + ..removeLast() + ..add("serializers.gql.dart"); @override Map> get buildExtensions => { @@ -51,22 +52,27 @@ class SerializerBuilder implements Builder { /// BuiltValue classes with serializers. These will be added automatically /// using `@SerializersFor`. - final builtClasses = SplayTreeSet((a, b) => a.name.compareTo(b.name)); + final builtClasses = + SplayTreeSet((a, b) => a.name.compareTo(b.name)); /// Non BuiltValue classes with serializers (i.e. inline fragment classes). /// These need to be added manually since `@SerializersFor` only recognizes /// BuiltValue classes. - final nonBuiltClasses = SplayTreeSet((a, b) => a.name.compareTo(b.name)); + final nonBuiltClasses = + SplayTreeSet((a, b) => a.name.compareTo(b.name)); final hasSerializer = (ClassElement c) => c.fields.any((field) => field.isStatic && field.name == "serializer" && field.type.element?.name == "Serializer" && - field.type.element?.source?.uri.toString() == "package:built_value/serializer.dart"); + field.type.element?.source?.uri.toString() == + "package:built_value/serializer.dart"); final isBuiltValue = (ClassElement c) => c.allSupertypes.any((interface) => - (interface.element.name == "Built" || interface.element.name == "EnumClass") && - interface.element.source.uri.toString() == "package:built_value/built_value.dart"); + (interface.element.name == "Built" || + interface.element.name == "EnumClass") && + interface.element.source.uri.toString() == + "package:built_value/built_value.dart"); await for (final input in buildStep.findAssets(_generatedFiles)) { final lib = await buildStep.resolver.libraryFor(input); diff --git a/codegen/gql_build/lib/src/var_builder.dart b/codegen/gql_build/lib/src/var_builder.dart index c6f9c4d0..8733b6b5 100644 --- a/codegen/gql_build/lib/src/var_builder.dart +++ b/codegen/gql_build/lib/src/var_builder.dart @@ -30,8 +30,10 @@ class VarBuilder implements Builder { final doc = await readDocument(buildStep); final schema = await readDocument(buildStep, schemaId); - final generatedPartUrl = - buildStep.inputId.changeExtension(generatedFileExtension(varExtension)).uri.path; + final generatedPartUrl = buildStep.inputId + .changeExtension(generatedFileExtension(varExtension)) + .uri + .path; final schemaUrl = outputAssetId(schemaId, schemaExtension).uri.toString(); final allocator = GqlAllocator( @@ -40,8 +42,8 @@ class VarBuilder implements Builder { schemaUrl, ); - final library = buildVarLibrary( - doc, addTypenames(schema), basename(generatedPartUrl), typeOverrides, allocator); + final library = buildVarLibrary(doc, addTypenames(schema), + basename(generatedPartUrl), typeOverrides, allocator); return writeDocument( library, diff --git a/codegen/gql_code_builder/lib/schema.dart b/codegen/gql_code_builder/lib/schema.dart index 71b22952..99da105a 100644 --- a/codegen/gql_code_builder/lib/schema.dart +++ b/codegen/gql_code_builder/lib/schema.dart @@ -42,7 +42,8 @@ Code buildPossibleTypes(DocumentNode document) { // wrap the map in a literal for codegen final possibleTypesLiteral = literalMap(possibleTypesMap); // assign the literal to a const variable named "possibleTypes" - return declareConst("possibleTypesMap", type: Reference("Map>")) + return declareConst("possibleTypesMap", + type: Reference("Map>")) .assign(possibleTypesLiteral) .statement; } diff --git a/codegen/gql_code_builder/lib/src/built_class.dart b/codegen/gql_code_builder/lib/src/built_class.dart index 48f75e34..9b92906e 100644 --- a/codegen/gql_code_builder/lib/src/built_class.dart +++ b/codegen/gql_code_builder/lib/src/built_class.dart @@ -78,10 +78,10 @@ Class builtClass({ ), if (getters != null) ...getters, // Serialization methods - if(!hasCustomSerializer) - buildSerializerGetter(className).rebuild( - (b) => b..body = Code("_\$${toCamelCase(className)}Serializer"), - ), + if (!hasCustomSerializer) + buildSerializerGetter(className).rebuild( + (b) => b..body = Code("_\$${toCamelCase(className)}Serializer"), + ), buildToJsonGetter( className, isOverride: superclassSelections.isNotEmpty, diff --git a/codegen/gql_code_builder/lib/src/common.dart b/codegen/gql_code_builder/lib/src/common.dart index ce9d5d4e..41fafe63 100644 --- a/codegen/gql_code_builder/lib/src/common.dart +++ b/codegen/gql_code_builder/lib/src/common.dart @@ -203,7 +203,8 @@ Method buildOptionalGetter({ ..isNullable = true ..url = "package:gql_exec/value.dart" ..symbol = "Value" - ..types.add((baseGetter.returns as TypeReference).rebuild((b3) => b3..isNullable = false)))); + ..types.add((baseGetter.returns as TypeReference) + .rebuild((b3) => b3..isNullable = false)))); return optionalGetter; } @@ -263,5 +264,6 @@ Method buildFromJsonGetter(String className) => Method( ..lambda = true ..body = refer("serializers", "#serializer") .property("deserializeWith") - .call([refer(className).property("serializer"), refer("json")]).code, + .call( + [refer(className).property("serializer"), refer("json")]).code, ); diff --git a/codegen/gql_code_builder/lib/src/schema.dart b/codegen/gql_code_builder/lib/src/schema.dart index 90307d4d..0b9d5f23 100644 --- a/codegen/gql_code_builder/lib/src/schema.dart +++ b/codegen/gql_code_builder/lib/src/schema.dart @@ -32,8 +32,8 @@ class _SchemaBuilderVisitor extends SimpleVisitor?> { final EnumFallbackConfig enumFallbackConfig; final Allocator allocator; - _SchemaBuilderVisitor( - this.schemaSource, this.typeOverrides, this.enumFallbackConfig, this.allocator); + _SchemaBuilderVisitor(this.schemaSource, this.typeOverrides, + this.enumFallbackConfig, this.allocator); @override List visitDocumentNode( @@ -58,8 +58,8 @@ class _SchemaBuilderVisitor extends SimpleVisitor?> { schemaSource, typeOverrides, ); - final serializer = - nullAwareJsonSerializerClass(inputClass, allocator, schemaSource, typeOverrides); + final serializer = nullAwareJsonSerializerClass( + inputClass, allocator, schemaSource, typeOverrides); return [inputClass, serializer]; } @@ -67,7 +67,9 @@ class _SchemaBuilderVisitor extends SimpleVisitor?> { List visitScalarTypeDefinitionNode( ScalarTypeDefinitionNode node, ) => - typeOverrides.containsKey(node.name.value) ? [] : [buildScalarClass(node)]; + typeOverrides.containsKey(node.name.value) + ? [] + : [buildScalarClass(node)]; @override List visitEnumTypeDefinitionNode( diff --git a/codegen/gql_code_builder/lib/src/schema/input.dart b/codegen/gql_code_builder/lib/src/schema/input.dart index b42997fb..4ce965d8 100644 --- a/codegen/gql_code_builder/lib/src/schema/input.dart +++ b/codegen/gql_code_builder/lib/src/schema/input.dart @@ -19,8 +19,8 @@ List buildInputClasses( schemaSource, typeOverrides, ); - final serializer = - nullAwareJsonSerializerClass(inputClass, allocator, schemaSource, typeOverrides); + final serializer = nullAwareJsonSerializerClass( + inputClass, allocator, schemaSource, typeOverrides); return [inputClass, serializer]; }).toList(); diff --git a/codegen/gql_code_builder/lib/var.dart b/codegen/gql_code_builder/lib/var.dart index 2e5ca1e1..a8bb4a49 100644 --- a/codegen/gql_code_builder/lib/var.dart +++ b/codegen/gql_code_builder/lib/var.dart @@ -33,13 +33,15 @@ Library buildVarLibrary( .toList(); Map _fragmentMap(SourceNode source) => { - for (var def in source.document.definitions.whereType()) + for (var def + in source.document.definitions.whereType()) def.name.value: def, for (var import in source.imports) ..._fragmentMap(import) }; - final fragmentVarClasses = - docSource.document.definitions.whereType().map((frag) { + final fragmentVarClasses = docSource.document.definitions + .whereType() + .map((frag) { final varTypes = fragmentVarTypes( fragment: frag, fragmentMap: _fragmentMap(docSource), @@ -86,18 +88,19 @@ Library buildVarLibrary( ); } -Method nullAwareJsonSerializerField(Node op, String className) => Method((b) => b - ..annotations - .add(CodeExpression(Code("BuiltValueSerializer(custom: true, serializeNulls: true)"))) - ..static = true - ..type = MethodType.getter - ..lambda = true - ..returns = TypeReference((b2) => b2 - ..symbol = "Serializer" - ..url = "package:built_value/serializer.dart" - ..types.add(refer(className))) - ..name = "serializer" - ..body = Code("${className}Serializer()")); +Method nullAwareJsonSerializerField(Node op, String className) => + Method((b) => b + ..annotations.add(CodeExpression( + Code("BuiltValueSerializer(custom: true, serializeNulls: true)"))) + ..static = true + ..type = MethodType.getter + ..lambda = true + ..returns = TypeReference((b2) => b2 + ..symbol = "Serializer" + ..url = "package:built_value/serializer.dart" + ..types.add(refer(className))) + ..name = "serializer" + ..body = Code("${className}Serializer()")); Class nullAwareJsonSerializerClass( Class base, @@ -131,7 +134,8 @@ Class nullAwareJsonSerializerClass( ..returns = refer("Iterable") ..requiredParameters.add(Parameter((b) => b ..name = "serializers" - ..type = refer("Serializers", "package:built_value/serializer.dart"))) + ..type = + refer("Serializers", "package:built_value/serializer.dart"))) ..requiredParameters.add(Parameter((b) => b ..name = "object" ..type = refer(base.name))) @@ -140,13 +144,15 @@ Class nullAwareJsonSerializerClass( ..named = true ..type = refer("FullType", "package:built_value/serializer.dart") ..defaultTo = Code("FullType.unspecified"))) - ..body = _serializerBody(base, allocator, schemaSource, typeOverrides)), + ..body = + _serializerBody(base, allocator, schemaSource, typeOverrides)), Method((b) => b ..name = "deserialize" ..returns = refer(base.name) ..requiredParameters.add(Parameter((b) => b ..name = "serializers" - ..type = refer("Serializers", "package:built_value/serializer.dart"))) + ..type = + refer("Serializers", "package:built_value/serializer.dart"))) ..requiredParameters.add(Parameter((b) => b ..name = "serialized" ..type = refer("Iterable"))) @@ -155,20 +161,22 @@ Class nullAwareJsonSerializerClass( ..named = true ..type = refer("FullType", "package:built_value/serializer.dart") ..defaultTo = Code("FullType.unspecified"))) - ..body = _deserializerBody(base, allocator, schemaSource, typeOverrides)), + ..body = + _deserializerBody(base, allocator, schemaSource, typeOverrides)), ])); Code _serializerBody(Class base, Allocator allocator, SourceNode schemaSource, Map typeOverrides) { final vars = []; - for (final field - in base.methods.where((field) => !field.static && field.type == MethodType.getter)) { + for (final field in base.methods + .where((field) => !field.static && field.type == MethodType.getter)) { final isOptionalValue = isValue(field.returns!); final statements = []; if (isOptionalValue) { - final realType = (field.returns as TypeReference).types.first as TypeReference; + final realType = + (field.returns as TypeReference).types.first as TypeReference; final _valueVarName = "_\$${field.name}value"; @@ -221,7 +229,9 @@ String _generateFieldDeserializers( SourceNode schemaSource, Map typeOverrides, ) => - clazz.methods.where((field) => field.type == MethodType.getter && !field.static).map((field) { + clazz.methods + .where((field) => field.type == MethodType.getter && !field.static) + .map((field) { var type = field.returns!; final isWrappedValue = isValue(type); if (isWrappedValue) { @@ -229,14 +239,18 @@ String _generateFieldDeserializers( } final fullType = _generateFullType(type as TypeReference, allocator); - final typeDefNode = getTypeDefinitionNode(schemaSource.document, type.symbol.substring(1)); + final typeDefNode = getTypeDefinitionNode( + schemaSource.document, type.symbol.substring(1)); - print(typeDefNode.runtimeType.toString() + " " + (typeDefNode?.name.value.toString() ?? "")); + print(typeDefNode.runtimeType.toString() + + " " + + (typeDefNode?.name.value.toString() ?? "")); //TODO this feels flaky, find a better way final isBuilder = type.url != null && !isWrappedValue && - (typeDefNode is! ScalarTypeDefinitionNode && typeDefNode is! EnumTypeDefinitionNode); + (typeDefNode is! ScalarTypeDefinitionNode && + typeDefNode is! EnumTypeDefinitionNode); /// TODO check for wireName @@ -289,9 +303,11 @@ bool isValue(Reference ref) { } String _getWireName(Method m) { - final annotation = - m.annotations.firstWhereOrNull((a) => a is InvokeExpression && a.name == "BuiltValueField") - as InvokeExpression?; + final annotation = m.annotations.firstWhereOrNull( + (a) => a is InvokeExpression && a.name == "BuiltValueField") + as InvokeExpression?; if (annotation == null) return m.name!; - return (annotation.namedArguments["wireName"] as LiteralExpression?)?.literal ?? m.name!; + return (annotation.namedArguments["wireName"] as LiteralExpression?) + ?.literal ?? + m.name!; } diff --git a/gql/lib/src/operation/definitions/selections.dart b/gql/lib/src/operation/definitions/selections.dart index eab6af9e..451607aa 100644 --- a/gql/lib/src/operation/definitions/selections.dart +++ b/gql/lib/src/operation/definitions/selections.dart @@ -56,7 +56,6 @@ abstract class Selection extends ExecutableWithResolver { static Selection fromNode( SelectionNode astNode, [ - /// The [schemaType] of the containing element TypeDefinition? schemaType, GetExecutableType? getType, diff --git a/links/gql_exec/lib/src/value.dart b/links/gql_exec/lib/src/value.dart index 0ab0b96a..c4b49ba2 100644 --- a/links/gql_exec/lib/src/value.dart +++ b/links/gql_exec/lib/src/value.dart @@ -11,7 +11,9 @@ class Value { @override bool operator ==(Object other) => identical(this, other) || - other is Value && runtimeType == other.runtimeType && _value == other._value; + other is Value && + runtimeType == other.runtimeType && + _value == other._value; @override int get hashCode => _value.hashCode; diff --git a/links/gql_link/lib/src/link.dart b/links/gql_link/lib/src/link.dart index 2e1f355c..73af9085 100644 --- a/links/gql_link/lib/src/link.dart +++ b/links/gql_link/lib/src/link.dart @@ -89,7 +89,6 @@ abstract class Link { Stream request( /// An incoming [Request] Request request, [ - /// Function that invokes the [request] function of /// the next [Link] /// From e4d20247a2dcc1671e51d3ddce41d7c3d9eb4749 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 12 Nov 2023 02:44:38 +0000 Subject: [PATCH 04/10] feat(gql_code_builder): make tri-state optional configurable, and end to end test with tri state null --- .github/workflows/dart.yml | 1 + .../alias_var_fragment.var.gql.dart | 93 +- .../alias_var_fragment.var.gql.g.dart | 86 + .../__generated__/aliased_hero.var.gql.dart | 48 +- .../__generated__/aliased_hero.var.gql.g.dart | 45 + .../fragment_with_scalar_var.var.gql.dart | 111 +- .../fragment_with_scalar_var.var.gql.g.dart | 106 +- .../hero_with_fragments.var.gql.dart | 163 +- .../hero_with_fragments.var.gql.g.dart | 139 +- ..._interface_subtyped_fragments.var.gql.dart | 177 +- ...nterface_subtyped_fragments.var.gql.g.dart | 131 + .../multiple_fragments.var.gql.dart | 143 +- .../multiple_fragments.var.gql.g.dart | 101 +- .../__generated__/schema.schema.gql.dart | 336 +-- .../__generated__/schema.schema.gql.g.dart | 344 ++- .../__generated__/serializers.gql.g.dart | 3 + .../hero_for_episode.var.gql.dart | 90 +- .../hero_for_episode.var.gql.g.dart | 73 + .../__generated__/hero_no_vars.var.gql.dart | 38 +- .../__generated__/hero_no_vars.var.gql.g.dart | 24 + .../review_with_date.var.gql.dart | 89 +- .../review_with_date.var.gql.g.dart | 99 +- .../create_custom_field.var.gql.dart | 52 +- .../create_custom_field.var.gql.g.dart | 50 + .../__generated__/create_review.var.gql.dart | 73 +- .../create_review.var.gql.g.dart | 75 +- .../human_with_args.var.gql.dart | 48 +- .../human_with_args.var.gql.g.dart | 45 + codegen/end_to_end_test/pubspec.yaml | 2 +- .../test/operation/variables_test.dart | 12 +- .../test/schema/input_test.dart | 17 +- .../test/schema/scalars_test.dart | 14 +- codegen/end_to_end_test_tristate/.gitignore | 11 + .../analysis_options.yaml | 7 + codegen/end_to_end_test_tristate/build.yaml | 60 + .../alias_var_fragment.ast.gql.dart | 113 + .../alias_var_fragment.data.gql.dart | 266 ++ .../alias_var_fragment.data.gql.g.dart | 1272 ++++++++ .../alias_var_fragment.req.gql.dart | 42 + .../alias_var_fragment.req.gql.g.dart | 170 ++ .../alias_var_fragment.var.gql.dart | 136 + .../alias_var_fragment.var.gql.g.dart | 176 ++ .../__generated__/aliased_hero.ast.gql.dart | 93 + .../__generated__/aliased_hero.data.gql.dart | 106 + .../aliased_hero.data.gql.g.dart | 653 +++++ .../__generated__/aliased_hero.req.gql.dart | 44 + .../__generated__/aliased_hero.req.gql.g.dart | 174 ++ .../__generated__/aliased_hero.var.gql.dart | 77 + .../__generated__/aliased_hero.var.gql.g.dart | 93 + .../lib/aliases/alias_var_fragment.graphql | 15 + .../lib/aliases/aliased_hero.graphql | 12 + .../lib/custom_field.dart | 31 + .../lib/custom_field_serializer.dart | 11 + .../lib/date_serializer.dart | 31 + .../fragment_with_scalar_var.ast.gql.dart | 88 + .../fragment_with_scalar_var.data.gql.dart | 203 ++ .../fragment_with_scalar_var.data.gql.g.dart | 955 ++++++ .../fragment_with_scalar_var.req.gql.dart | 46 + .../fragment_with_scalar_var.req.gql.g.dart | 186 ++ .../fragment_with_scalar_var.var.gql.dart | 140 + .../fragment_with_scalar_var.var.gql.g.dart | 155 + .../hero_with_fragments.ast.gql.dart | 126 + .../hero_with_fragments.data.gql.dart | 419 +++ .../hero_with_fragments.data.gql.g.dart | 1992 +++++++++++++ .../hero_with_fragments.req.gql.dart | 45 + .../hero_with_fragments.req.gql.g.dart | 180 ++ .../hero_with_fragments.var.gql.dart | 199 ++ .../hero_with_fragments.var.gql.g.dart | 230 ++ ..._interface_subtyped_fragments.ast.gql.dart | 203 ++ ...interface_subtyped_fragments.data.gql.dart | 946 ++++++ ...terface_subtyped_fragments.data.gql.g.dart | 2592 +++++++++++++++++ ..._interface_subtyped_fragments.req.gql.dart | 51 + ...nterface_subtyped_fragments.req.gql.g.dart | 197 ++ ..._interface_subtyped_fragments.var.gql.dart | 236 ++ ...nterface_subtyped_fragments.var.gql.g.dart | 289 ++ .../multiple_fragments.ast.gql.dart | 86 + .../multiple_fragments.data.gql.dart | 148 + .../multiple_fragments.data.gql.g.dart | 666 +++++ .../multiple_fragments.req.gql.dart | 45 + .../multiple_fragments.req.gql.g.dart | 183 ++ .../multiple_fragments.var.gql.dart | 172 ++ .../multiple_fragments.var.gql.g.dart | 206 ++ .../fragment_with_scalar_var.graphql | 13 + .../lib/fragments/hero_with_fragments.graphql | 22 + ..._with_interface_subtyped_fragments.graphql | 38 + .../lib/fragments/multiple_fragments.graphql | 17 + .../graphql/__generated__/schema.ast.gql.dart | 1181 ++++++++ .../__generated__/schema.schema.gql.dart | 476 +++ .../__generated__/schema.schema.gql.g.dart | 758 +++++ .../__generated__/serializers.gql.dart | 264 ++ .../__generated__/serializers.gql.g.dart | 167 ++ .../lib/graphql/schema.graphql | 213 ++ .../hero_for_episode.ast.gql.dart | 95 + .../hero_for_episode.data.gql.dart | 290 ++ .../hero_for_episode.data.gql.g.dart | 1110 +++++++ .../hero_for_episode.req.gql.dart | 45 + .../hero_for_episode.req.gql.g.dart | 177 ++ .../hero_for_episode.var.gql.dart | 126 + .../hero_for_episode.var.gql.g.dart | 154 + .../lib/interfaces/hero_for_episode.graphql | 15 + .../__generated__/hero_no_vars.ast.gql.dart | 37 + .../__generated__/hero_no_vars.data.gql.dart | 68 + .../hero_no_vars.data.gql.g.dart | 358 +++ .../__generated__/hero_no_vars.req.gql.dart | 42 + .../__generated__/hero_no_vars.req.gql.g.dart | 171 ++ .../__generated__/hero_no_vars.var.gql.dart | 55 + .../__generated__/hero_no_vars.var.gql.g.dart | 67 + .../lib/no_vars/hero_no_vars.graphql | 6 + .../review_with_date.ast.gql.dart | 106 + .../review_with_date.data.gql.dart | 79 + .../review_with_date.data.gql.g.dart | 487 ++++ .../review_with_date.req.gql.dart | 45 + .../review_with_date.req.gql.g.dart | 177 ++ .../review_with_date.var.gql.dart | 110 + .../review_with_date.var.gql.g.dart | 134 + .../lib/scalars/review_with_date.graphql | 14 + .../create_custom_field.ast.gql.dart | 37 + .../create_custom_field.data.gql.dart | 40 + .../create_custom_field.data.gql.g.dart | 174 ++ .../create_custom_field.req.gql.dart | 45 + .../create_custom_field.req.gql.g.dart | 180 ++ .../create_custom_field.var.gql.dart | 82 + .../create_custom_field.var.gql.g.dart | 107 + .../__generated__/create_review.ast.gql.dart | 72 + .../__generated__/create_review.data.gql.dart | 73 + .../create_review.data.gql.g.dart | 393 +++ .../__generated__/create_review.req.gql.dart | 44 + .../create_review.req.gql.g.dart | 174 ++ .../__generated__/create_review.var.gql.dart | 94 + .../create_review.var.gql.g.dart | 120 + .../human_with_args.ast.gql.dart | 52 + .../human_with_args.data.gql.dart | 69 + .../human_with_args.data.gql.g.dart | 365 +++ .../human_with_args.req.gql.dart | 45 + .../human_with_args.req.gql.g.dart | 177 ++ .../human_with_args.var.gql.dart | 75 + .../human_with_args.var.gql.g.dart | 94 + .../lib/variables/create_custom_field.graphql | 5 + .../lib/variables/create_review.graphql | 7 + .../lib/variables/human_with_args.graphql | 6 + codegen/end_to_end_test_tristate/pubspec.yaml | 17 + .../operation_serializer_test.dart | 29 + .../test/data/when_extension_test.dart | 146 + .../test/operation/aliases_test.dart | 38 + .../fragments_inline_nesting_test.dart | 98 + .../test/operation/fragments_test.dart | 65 + .../test/operation/interfaces_test.dart | 67 + .../test/operation/requests_test.dart | 41 + .../test/operation/variables_test.dart | 49 + .../test/schema/enums_test.dart | 24 + .../test/schema/input_test.dart | 37 + .../test/schema/scalars_test.dart | 135 + codegen/gql_build/lib/gql_build.dart | 18 +- codegen/gql_build/lib/src/schema_builder.dart | 15 +- codegen/gql_build/lib/src/utils/config.dart | 13 + codegen/gql_build/lib/src/var_builder.dart | 12 +- codegen/gql_code_builder/lib/schema.dart | 13 +- codegen/gql_code_builder/lib/src/common.dart | 9 +- codegen/gql_code_builder/lib/src/schema.dart | 24 +- .../lib/src/schema/input.dart | 10 +- codegen/gql_code_builder/lib/var.dart | 147 +- links/gql_exec/lib/src/value.dart | 20 +- 162 files changed, 26566 insertions(+), 1513 deletions(-) create mode 100644 codegen/end_to_end_test_tristate/.gitignore create mode 100644 codegen/end_to_end_test_tristate/analysis_options.yaml create mode 100644 codegen/end_to_end_test_tristate/build.yaml create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.ast.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.data.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.data.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.req.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.req.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.ast.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.data.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.data.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.req.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.req.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/alias_var_fragment.graphql create mode 100644 codegen/end_to_end_test_tristate/lib/aliases/aliased_hero.graphql create mode 100644 codegen/end_to_end_test_tristate/lib/custom_field.dart create mode 100644 codegen/end_to_end_test_tristate/lib/custom_field_serializer.dart create mode 100644 codegen/end_to_end_test_tristate/lib/date_serializer.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.ast.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.req.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.req.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.ast.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.data.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.data.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.req.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.req.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.ast.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.req.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.req.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.ast.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.data.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.data.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.req.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.req.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/fragment_with_scalar_var.graphql create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/hero_with_fragments.graphql create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/hero_with_interface_subtyped_fragments.graphql create mode 100644 codegen/end_to_end_test_tristate/lib/fragments/multiple_fragments.graphql create mode 100644 codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.ast.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/graphql/__generated__/serializers.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/graphql/__generated__/serializers.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/graphql/schema.graphql create mode 100644 codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.ast.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.data.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.data.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.req.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.req.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/interfaces/hero_for_episode.graphql create mode 100644 codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.ast.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.data.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.data.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.req.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.req.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.var.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.var.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/no_vars/hero_no_vars.graphql create mode 100644 codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.ast.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.data.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.data.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.req.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.req.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/scalars/review_with_date.graphql create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.ast.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.data.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.data.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.req.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.req.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.ast.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.data.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.data.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.req.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.req.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.ast.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.data.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.data.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.req.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.req.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.g.dart create mode 100644 codegen/end_to_end_test_tristate/lib/variables/create_custom_field.graphql create mode 100644 codegen/end_to_end_test_tristate/lib/variables/create_review.graphql create mode 100644 codegen/end_to_end_test_tristate/lib/variables/human_with_args.graphql create mode 100644 codegen/end_to_end_test_tristate/pubspec.yaml create mode 100644 codegen/end_to_end_test_tristate/test/custom_serializers/operation_serializer_test.dart create mode 100644 codegen/end_to_end_test_tristate/test/data/when_extension_test.dart create mode 100644 codegen/end_to_end_test_tristate/test/operation/aliases_test.dart create mode 100644 codegen/end_to_end_test_tristate/test/operation/fragments_inline_nesting_test.dart create mode 100644 codegen/end_to_end_test_tristate/test/operation/fragments_test.dart create mode 100644 codegen/end_to_end_test_tristate/test/operation/interfaces_test.dart create mode 100644 codegen/end_to_end_test_tristate/test/operation/requests_test.dart create mode 100644 codegen/end_to_end_test_tristate/test/operation/variables_test.dart create mode 100644 codegen/end_to_end_test_tristate/test/schema/enums_test.dart create mode 100644 codegen/end_to_end_test_tristate/test/schema/input_test.dart create mode 100644 codegen/end_to_end_test_tristate/test/schema/scalars_test.dart diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 3b5fd0cd..8e73f44f 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -125,6 +125,7 @@ jobs: matrix: package: - end_to_end_test + - end_to_end_test_tristate runs-on: ubuntu-latest container: image: dart diff --git a/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.var.gql.dart b/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.var.gql.dart index c8acec58..a57a54a4 100644 --- a/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.var.gql.dart +++ b/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.var.gql.dart @@ -15,6 +15,8 @@ abstract class GPostsVars implements Built { factory GPostsVars([Function(GPostsVarsBuilder b) updates]) = _$GPostsVars; String get userId; + static Serializer get serializer => _$gPostsVarsSerializer; + Map toJson() => (_i1.serializers.serializeWith( GPostsVars.serializer, this, @@ -25,9 +27,6 @@ abstract class GPostsVars implements Built { GPostsVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => GPostsVarsSerializer(); } abstract class GPostFragmentVars @@ -38,6 +37,9 @@ abstract class GPostFragmentVars _$GPostFragmentVars; String get userId; + static Serializer get serializer => + _$gPostFragmentVarsSerializer; + Map toJson() => (_i1.serializers.serializeWith( GPostFragmentVars.serializer, this, @@ -48,89 +50,4 @@ abstract class GPostFragmentVars GPostFragmentVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GPostFragmentVarsSerializer(); -} - -class GPostsVarsSerializer extends StructuredSerializer { - final String wireName = 'GPostsVars'; - - final Iterable types = const [GPostsVars, _$GPostsVars]; - - Iterable serialize( - Serializers serializers, - GPostsVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - result.add('userId'); - result.add(serializers.serialize(object.userId, - specifiedType: const FullType(String))); - return result; - } - - GPostsVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GPostsVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'userId': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - builder.userId = fieldValue; - break; - } - } - return builder.build(); - } -} - -class GPostFragmentVarsSerializer - extends StructuredSerializer { - final String wireName = 'GPostFragmentVars'; - - final Iterable types = const [GPostFragmentVars, _$GPostFragmentVars]; - - Iterable serialize( - Serializers serializers, - GPostFragmentVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - result.add('userId'); - result.add(serializers.serialize(object.userId, - specifiedType: const FullType(String))); - return result; - } - - GPostFragmentVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GPostFragmentVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'userId': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - builder.userId = fieldValue; - break; - } - } - return builder.build(); - } } diff --git a/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.var.gql.g.dart b/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.var.gql.g.dart index fdce65cf..5a3b87ac 100644 --- a/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.var.gql.g.dart @@ -6,6 +6,92 @@ part of 'alias_var_fragment.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** +Serializer _$gPostsVarsSerializer = new _$GPostsVarsSerializer(); +Serializer _$gPostFragmentVarsSerializer = + new _$GPostFragmentVarsSerializer(); + +class _$GPostsVarsSerializer implements StructuredSerializer { + @override + final Iterable types = const [GPostsVars, _$GPostsVars]; + @override + final String wireName = 'GPostsVars'; + + @override + Iterable serialize(Serializers serializers, GPostsVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'userId', + serializers.serialize(object.userId, + specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GPostsVars deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostsVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'userId': + result.userId = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GPostFragmentVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GPostFragmentVars, _$GPostFragmentVars]; + @override + final String wireName = 'GPostFragmentVars'; + + @override + Iterable serialize(Serializers serializers, GPostFragmentVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'userId', + serializers.serialize(object.userId, + specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GPostFragmentVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostFragmentVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'userId': + result.userId = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + class _$GPostsVars extends GPostsVars { @override final String userId; diff --git a/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.dart b/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.dart index f6f76dee..f4d2ee29 100644 --- a/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.dart +++ b/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.dart @@ -19,6 +19,9 @@ abstract class GAliasedHeroVars _$GAliasedHeroVars; _i1.GEpisode get ep; + static Serializer get serializer => + _$gAliasedHeroVarsSerializer; + Map toJson() => (_i2.serializers.serializeWith( GAliasedHeroVars.serializer, this, @@ -29,49 +32,4 @@ abstract class GAliasedHeroVars GAliasedHeroVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GAliasedHeroVarsSerializer(); -} - -class GAliasedHeroVarsSerializer - extends StructuredSerializer { - final String wireName = 'GAliasedHeroVars'; - - final Iterable types = const [GAliasedHeroVars, _$GAliasedHeroVars]; - - Iterable serialize( - Serializers serializers, - GAliasedHeroVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - result.add('ep'); - result.add(serializers.serialize(object.ep, - specifiedType: const FullType(_i1.GEpisode))); - return result; - } - - GAliasedHeroVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GAliasedHeroVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'ep': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; - builder.ep = fieldValue; - break; - } - } - return builder.build(); - } } diff --git a/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.g.dart b/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.g.dart index eb6a4801..89fe20ab 100644 --- a/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/aliases/__generated__/aliased_hero.var.gql.g.dart @@ -6,6 +6,51 @@ part of 'aliased_hero.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** +Serializer _$gAliasedHeroVarsSerializer = + new _$GAliasedHeroVarsSerializer(); + +class _$GAliasedHeroVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GAliasedHeroVars, _$GAliasedHeroVars]; + @override + final String wireName = 'GAliasedHeroVars'; + + @override + Iterable serialize(Serializers serializers, GAliasedHeroVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'ep', + serializers.serialize(object.ep, + specifiedType: const FullType(_i1.GEpisode)), + ]; + + return result; + } + + @override + GAliasedHeroVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GAliasedHeroVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'ep': + result.ep = serializers.deserialize(value, + specifiedType: const FullType(_i1.GEpisode))! as _i1.GEpisode; + break; + } + } + + return result.build(); + } +} + class _$GAliasedHeroVars extends GAliasedHeroVars { @override final _i1.GEpisode ep; diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart index 1f8910c4..1eb7bd4d 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart @@ -5,10 +5,9 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart' - as _i2; + as _i1; import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' - as _i3; -import 'package:gql_exec/value.dart' as _i1; + as _i2; part 'fragment_with_scalar_var.var.gql.g.dart'; @@ -21,21 +20,20 @@ abstract class GPostsWithFixedVariableVars [Function(GPostsWithFixedVariableVarsBuilder b) updates]) = _$GPostsWithFixedVariableVars; - _i1.Value<_i2.GJson>? get filter; - Map toJson() => (_i3.serializers.serializeWith( + _i1.GJson? get filter; + static Serializer get serializer => + _$gPostsWithFixedVariableVarsSerializer; + + Map toJson() => (_i2.serializers.serializeWith( GPostsWithFixedVariableVars.serializer, this, ) as Map); static GPostsWithFixedVariableVars? fromJson(Map json) => - _i3.serializers.deserializeWith( + _i2.serializers.deserializeWith( GPostsWithFixedVariableVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GPostsWithFixedVariableVarsSerializer(); } abstract class GPostFragmentForUser1Vars @@ -47,100 +45,17 @@ abstract class GPostFragmentForUser1Vars [Function(GPostFragmentForUser1VarsBuilder b) updates]) = _$GPostFragmentForUser1Vars; - Map toJson() => (_i3.serializers.serializeWith( + static Serializer get serializer => + _$gPostFragmentForUser1VarsSerializer; + + Map toJson() => (_i2.serializers.serializeWith( GPostFragmentForUser1Vars.serializer, this, ) as Map); static GPostFragmentForUser1Vars? fromJson(Map json) => - _i3.serializers.deserializeWith( + _i2.serializers.deserializeWith( GPostFragmentForUser1Vars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GPostFragmentForUser1VarsSerializer(); -} - -class GPostsWithFixedVariableVarsSerializer - extends StructuredSerializer { - final String wireName = 'GPostsWithFixedVariableVars'; - - final Iterable types = const [ - GPostsWithFixedVariableVars, - _$GPostsWithFixedVariableVars - ]; - - Iterable serialize( - Serializers serializers, - GPostsWithFixedVariableVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - final _$filtervalue = object.filter; - if (_$filtervalue case _i1.PresentValue(value: final _$value)) { - result.add('filter'); - result.add(serializers.serialize(_$value, - specifiedType: const FullType(_i2.GJson))); - } - return result; - } - - GPostsWithFixedVariableVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GPostsWithFixedVariableVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'filter': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(_i2.GJson)) as _i2.GJson; - builder.filter = _i1.PresentValue(fieldValue); - break; - } - } - return builder.build(); - } -} - -class GPostFragmentForUser1VarsSerializer - extends StructuredSerializer { - final String wireName = 'GPostFragmentForUser1Vars'; - - final Iterable types = const [ - GPostFragmentForUser1Vars, - _$GPostFragmentForUser1Vars - ]; - - Iterable serialize( - Serializers serializers, - GPostFragmentForUser1Vars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - return result; - } - - GPostFragmentForUser1Vars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GPostFragmentForUser1VarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) {} - } - return builder.build(); - } } diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.g.dart index 26f9fe6f..f127555f 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.g.dart @@ -6,9 +6,89 @@ part of 'fragment_with_scalar_var.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** +Serializer + _$gPostsWithFixedVariableVarsSerializer = + new _$GPostsWithFixedVariableVarsSerializer(); +Serializer _$gPostFragmentForUser1VarsSerializer = + new _$GPostFragmentForUser1VarsSerializer(); + +class _$GPostsWithFixedVariableVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GPostsWithFixedVariableVars, + _$GPostsWithFixedVariableVars + ]; + @override + final String wireName = 'GPostsWithFixedVariableVars'; + + @override + Iterable serialize( + Serializers serializers, GPostsWithFixedVariableVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + Object? value; + value = object.filter; + if (value != null) { + result + ..add('filter') + ..add(serializers.serialize(value, + specifiedType: const FullType(_i1.GJson))); + } + return result; + } + + @override + GPostsWithFixedVariableVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostsWithFixedVariableVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'filter': + result.filter.replace(serializers.deserialize(value, + specifiedType: const FullType(_i1.GJson))! as _i1.GJson); + break; + } + } + + return result.build(); + } +} + +class _$GPostFragmentForUser1VarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GPostFragmentForUser1Vars, + _$GPostFragmentForUser1Vars + ]; + @override + final String wireName = 'GPostFragmentForUser1Vars'; + + @override + Iterable serialize( + Serializers serializers, GPostFragmentForUser1Vars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GPostFragmentForUser1Vars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GPostFragmentForUser1VarsBuilder().build(); + } +} + class _$GPostsWithFixedVariableVars extends GPostsWithFixedVariableVars { @override - final _i1.Value<_i2.GJson>? filter; + final _i1.GJson? filter; factory _$GPostsWithFixedVariableVars( [void Function(GPostsWithFixedVariableVarsBuilder)? updates]) => @@ -53,16 +133,16 @@ class GPostsWithFixedVariableVarsBuilder GPostsWithFixedVariableVarsBuilder> { _$GPostsWithFixedVariableVars? _$v; - _i1.Value<_i2.GJson>? _filter; - _i1.Value<_i2.GJson>? get filter => _$this._filter; - set filter(_i1.Value<_i2.GJson>? filter) => _$this._filter = filter; + _i1.GJsonBuilder? _filter; + _i1.GJsonBuilder get filter => _$this._filter ??= new _i1.GJsonBuilder(); + set filter(_i1.GJsonBuilder? filter) => _$this._filter = filter; GPostsWithFixedVariableVarsBuilder(); GPostsWithFixedVariableVarsBuilder get _$this { final $v = _$v; if ($v != null) { - _filter = $v.filter; + _filter = $v.filter?.toBuilder(); _$v = null; } return this; @@ -83,7 +163,21 @@ class GPostsWithFixedVariableVarsBuilder GPostsWithFixedVariableVars build() => _build(); _$GPostsWithFixedVariableVars _build() { - final _$result = _$v ?? new _$GPostsWithFixedVariableVars._(filter: filter); + _$GPostsWithFixedVariableVars _$result; + try { + _$result = + _$v ?? new _$GPostsWithFixedVariableVars._(filter: _filter?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'filter'; + _filter?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GPostsWithFixedVariableVars', _$failedField, e.toString()); + } + rethrow; + } replace(_$result); return _$result; } diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.dart index e64aa5a8..cb0a4709 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.dart @@ -5,8 +5,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' - as _i2; -import 'package:gql_exec/value.dart' as _i1; + as _i1; part 'hero_with_fragments.var.gql.g.dart'; @@ -18,21 +17,20 @@ abstract class GHeroWithFragmentsVars [Function(GHeroWithFragmentsVarsBuilder b) updates]) = _$GHeroWithFragmentsVars; - _i1.Value? get first; - Map toJson() => (_i2.serializers.serializeWith( + int? get first; + static Serializer get serializer => + _$gHeroWithFragmentsVarsSerializer; + + Map toJson() => (_i1.serializers.serializeWith( GHeroWithFragmentsVars.serializer, this, ) as Map); static GHeroWithFragmentsVars? fromJson(Map json) => - _i2.serializers.deserializeWith( + _i1.serializers.deserializeWith( GHeroWithFragmentsVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GHeroWithFragmentsVarsSerializer(); } abstract class GheroDataVars @@ -42,19 +40,18 @@ abstract class GheroDataVars factory GheroDataVars([Function(GheroDataVarsBuilder b) updates]) = _$GheroDataVars; - Map toJson() => (_i2.serializers.serializeWith( + static Serializer get serializer => _$gheroDataVarsSerializer; + + Map toJson() => (_i1.serializers.serializeWith( GheroDataVars.serializer, this, ) as Map); static GheroDataVars? fromJson(Map json) => - _i2.serializers.deserializeWith( + _i1.serializers.deserializeWith( GheroDataVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => GheroDataVarsSerializer(); } abstract class GcomparisonFieldsVars @@ -65,144 +62,18 @@ abstract class GcomparisonFieldsVars [Function(GcomparisonFieldsVarsBuilder b) updates]) = _$GcomparisonFieldsVars; - _i1.Value? get first; - Map toJson() => (_i2.serializers.serializeWith( + int? get first; + static Serializer get serializer => + _$gcomparisonFieldsVarsSerializer; + + Map toJson() => (_i1.serializers.serializeWith( GcomparisonFieldsVars.serializer, this, ) as Map); static GcomparisonFieldsVars? fromJson(Map json) => - _i2.serializers.deserializeWith( + _i1.serializers.deserializeWith( GcomparisonFieldsVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GcomparisonFieldsVarsSerializer(); -} - -class GHeroWithFragmentsVarsSerializer - extends StructuredSerializer { - final String wireName = 'GHeroWithFragmentsVars'; - - final Iterable types = const [ - GHeroWithFragmentsVars, - _$GHeroWithFragmentsVars - ]; - - Iterable serialize( - Serializers serializers, - GHeroWithFragmentsVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - final _$firstvalue = object.first; - if (_$firstvalue case _i1.PresentValue(value: final _$value)) { - result.add('first'); - result.add( - serializers.serialize(_$value, specifiedType: const FullType(int))); - } - return result; - } - - GHeroWithFragmentsVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GHeroWithFragmentsVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'first': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - builder.first = _i1.PresentValue(fieldValue); - break; - } - } - return builder.build(); - } -} - -class GheroDataVarsSerializer extends StructuredSerializer { - final String wireName = 'GheroDataVars'; - - final Iterable types = const [GheroDataVars, _$GheroDataVars]; - - Iterable serialize( - Serializers serializers, - GheroDataVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - return result; - } - - GheroDataVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GheroDataVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) {} - } - return builder.build(); - } -} - -class GcomparisonFieldsVarsSerializer - extends StructuredSerializer { - final String wireName = 'GcomparisonFieldsVars'; - - final Iterable types = const [ - GcomparisonFieldsVars, - _$GcomparisonFieldsVars - ]; - - Iterable serialize( - Serializers serializers, - GcomparisonFieldsVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - final _$firstvalue = object.first; - if (_$firstvalue case _i1.PresentValue(value: final _$value)) { - result.add('first'); - result.add( - serializers.serialize(_$value, specifiedType: const FullType(int))); - } - return result; - } - - GcomparisonFieldsVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GcomparisonFieldsVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'first': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - builder.first = _i1.PresentValue(fieldValue); - break; - } - } - return builder.build(); - } } diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.g.dart index 08041e98..dd38fb44 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.var.gql.g.dart @@ -6,9 +6,132 @@ part of 'hero_with_fragments.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** +Serializer _$gHeroWithFragmentsVarsSerializer = + new _$GHeroWithFragmentsVarsSerializer(); +Serializer _$gheroDataVarsSerializer = + new _$GheroDataVarsSerializer(); +Serializer _$gcomparisonFieldsVarsSerializer = + new _$GcomparisonFieldsVarsSerializer(); + +class _$GHeroWithFragmentsVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroWithFragmentsVars, + _$GHeroWithFragmentsVars + ]; + @override + final String wireName = 'GHeroWithFragmentsVars'; + + @override + Iterable serialize( + Serializers serializers, GHeroWithFragmentsVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + Object? value; + value = object.first; + if (value != null) { + result + ..add('first') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + return result; + } + + @override + GHeroWithFragmentsVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroWithFragmentsVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'first': + result.first = serializers.deserialize(value, + specifiedType: const FullType(int)) as int?; + break; + } + } + + return result.build(); + } +} + +class _$GheroDataVarsSerializer implements StructuredSerializer { + @override + final Iterable types = const [GheroDataVars, _$GheroDataVars]; + @override + final String wireName = 'GheroDataVars'; + + @override + Iterable serialize(Serializers serializers, GheroDataVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GheroDataVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GheroDataVarsBuilder().build(); + } +} + +class _$GcomparisonFieldsVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GcomparisonFieldsVars, + _$GcomparisonFieldsVars + ]; + @override + final String wireName = 'GcomparisonFieldsVars'; + + @override + Iterable serialize( + Serializers serializers, GcomparisonFieldsVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + Object? value; + value = object.first; + if (value != null) { + result + ..add('first') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + return result; + } + + @override + GcomparisonFieldsVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GcomparisonFieldsVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'first': + result.first = serializers.deserialize(value, + specifiedType: const FullType(int)) as int?; + break; + } + } + + return result.build(); + } +} + class _$GHeroWithFragmentsVars extends GHeroWithFragmentsVars { @override - final _i1.Value? first; + final int? first; factory _$GHeroWithFragmentsVars( [void Function(GHeroWithFragmentsVarsBuilder)? updates]) => @@ -51,9 +174,9 @@ class GHeroWithFragmentsVarsBuilder implements Builder { _$GHeroWithFragmentsVars? _$v; - _i1.Value? _first; - _i1.Value? get first => _$this._first; - set first(_i1.Value? first) => _$this._first = first; + int? _first; + int? get first => _$this._first; + set first(int? first) => _$this._first = first; GHeroWithFragmentsVarsBuilder(); @@ -146,7 +269,7 @@ class GheroDataVarsBuilder class _$GcomparisonFieldsVars extends GcomparisonFieldsVars { @override - final _i1.Value? first; + final int? first; factory _$GcomparisonFieldsVars( [void Function(GcomparisonFieldsVarsBuilder)? updates]) => @@ -189,9 +312,9 @@ class GcomparisonFieldsVarsBuilder implements Builder { _$GcomparisonFieldsVars? _$v; - _i1.Value? _first; - _i1.Value? get first => _$this._first; - set first(_i1.Value? first) => _$this._first = first; + int? _first; + int? get first => _$this._first; + set first(int? first) => _$this._first = first; GcomparisonFieldsVarsBuilder(); diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart index 08c376ca..6ea5ff77 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart @@ -22,6 +22,9 @@ abstract class GHeroWithInterfaceSubTypedFragmentsVars updates]) = _$GHeroWithInterfaceSubTypedFragmentsVars; _i1.GEpisode get episode; + static Serializer get serializer => + _$gHeroWithInterfaceSubTypedFragmentsVarsSerializer; + Map toJson() => (_i2.serializers.serializeWith( GHeroWithInterfaceSubTypedFragmentsVars.serializer, this, @@ -33,10 +36,6 @@ abstract class GHeroWithInterfaceSubTypedFragmentsVars GHeroWithInterfaceSubTypedFragmentsVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GHeroWithInterfaceSubTypedFragmentsVarsSerializer(); } abstract class GheroFieldsFragmentVars @@ -47,6 +46,9 @@ abstract class GheroFieldsFragmentVars [Function(GheroFieldsFragmentVarsBuilder b) updates]) = _$GheroFieldsFragmentVars; + static Serializer get serializer => + _$gheroFieldsFragmentVarsSerializer; + Map toJson() => (_i2.serializers.serializeWith( GheroFieldsFragmentVars.serializer, this, @@ -57,10 +59,6 @@ abstract class GheroFieldsFragmentVars GheroFieldsFragmentVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GheroFieldsFragmentVarsSerializer(); } abstract class GhumanFieldsFragmentVars @@ -72,6 +70,9 @@ abstract class GhumanFieldsFragmentVars [Function(GhumanFieldsFragmentVarsBuilder b) updates]) = _$GhumanFieldsFragmentVars; + static Serializer get serializer => + _$ghumanFieldsFragmentVarsSerializer; + Map toJson() => (_i2.serializers.serializeWith( GhumanFieldsFragmentVars.serializer, this, @@ -82,10 +83,6 @@ abstract class GhumanFieldsFragmentVars GhumanFieldsFragmentVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GhumanFieldsFragmentVarsSerializer(); } abstract class GdroidFieldsFragmentVars @@ -97,6 +94,9 @@ abstract class GdroidFieldsFragmentVars [Function(GdroidFieldsFragmentVarsBuilder b) updates]) = _$GdroidFieldsFragmentVars; + static Serializer get serializer => + _$gdroidFieldsFragmentVarsSerializer; + Map toJson() => (_i2.serializers.serializeWith( GdroidFieldsFragmentVars.serializer, this, @@ -107,157 +107,4 @@ abstract class GdroidFieldsFragmentVars GdroidFieldsFragmentVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GdroidFieldsFragmentVarsSerializer(); -} - -class GHeroWithInterfaceSubTypedFragmentsVarsSerializer - extends StructuredSerializer { - final String wireName = 'GHeroWithInterfaceSubTypedFragmentsVars'; - - final Iterable types = const [ - GHeroWithInterfaceSubTypedFragmentsVars, - _$GHeroWithInterfaceSubTypedFragmentsVars - ]; - - Iterable serialize( - Serializers serializers, - GHeroWithInterfaceSubTypedFragmentsVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - result.add('episode'); - result.add(serializers.serialize(object.episode, - specifiedType: const FullType(_i1.GEpisode))); - return result; - } - - GHeroWithInterfaceSubTypedFragmentsVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GHeroWithInterfaceSubTypedFragmentsVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'episode': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; - builder.episode = fieldValue; - break; - } - } - return builder.build(); - } -} - -class GheroFieldsFragmentVarsSerializer - extends StructuredSerializer { - final String wireName = 'GheroFieldsFragmentVars'; - - final Iterable types = const [ - GheroFieldsFragmentVars, - _$GheroFieldsFragmentVars - ]; - - Iterable serialize( - Serializers serializers, - GheroFieldsFragmentVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - return result; - } - - GheroFieldsFragmentVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GheroFieldsFragmentVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) {} - } - return builder.build(); - } -} - -class GhumanFieldsFragmentVarsSerializer - extends StructuredSerializer { - final String wireName = 'GhumanFieldsFragmentVars'; - - final Iterable types = const [ - GhumanFieldsFragmentVars, - _$GhumanFieldsFragmentVars - ]; - - Iterable serialize( - Serializers serializers, - GhumanFieldsFragmentVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - return result; - } - - GhumanFieldsFragmentVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GhumanFieldsFragmentVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) {} - } - return builder.build(); - } -} - -class GdroidFieldsFragmentVarsSerializer - extends StructuredSerializer { - final String wireName = 'GdroidFieldsFragmentVars'; - - final Iterable types = const [ - GdroidFieldsFragmentVars, - _$GdroidFieldsFragmentVars - ]; - - Iterable serialize( - Serializers serializers, - GdroidFieldsFragmentVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - return result; - } - - GdroidFieldsFragmentVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GdroidFieldsFragmentVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) {} - } - return builder.build(); - } } diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.g.dart index 0689f5b4..ce583215 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.g.dart @@ -6,6 +6,137 @@ part of 'hero_with_interface_subtyped_fragments.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** +Serializer + _$gHeroWithInterfaceSubTypedFragmentsVarsSerializer = + new _$GHeroWithInterfaceSubTypedFragmentsVarsSerializer(); +Serializer _$gheroFieldsFragmentVarsSerializer = + new _$GheroFieldsFragmentVarsSerializer(); +Serializer _$ghumanFieldsFragmentVarsSerializer = + new _$GhumanFieldsFragmentVarsSerializer(); +Serializer _$gdroidFieldsFragmentVarsSerializer = + new _$GdroidFieldsFragmentVarsSerializer(); + +class _$GHeroWithInterfaceSubTypedFragmentsVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroWithInterfaceSubTypedFragmentsVars, + _$GHeroWithInterfaceSubTypedFragmentsVars + ]; + @override + final String wireName = 'GHeroWithInterfaceSubTypedFragmentsVars'; + + @override + Iterable serialize( + Serializers serializers, GHeroWithInterfaceSubTypedFragmentsVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'episode', + serializers.serialize(object.episode, + specifiedType: const FullType(_i1.GEpisode)), + ]; + + return result; + } + + @override + GHeroWithInterfaceSubTypedFragmentsVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroWithInterfaceSubTypedFragmentsVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'episode': + result.episode = serializers.deserialize(value, + specifiedType: const FullType(_i1.GEpisode))! as _i1.GEpisode; + break; + } + } + + return result.build(); + } +} + +class _$GheroFieldsFragmentVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GheroFieldsFragmentVars, + _$GheroFieldsFragmentVars + ]; + @override + final String wireName = 'GheroFieldsFragmentVars'; + + @override + Iterable serialize( + Serializers serializers, GheroFieldsFragmentVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GheroFieldsFragmentVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GheroFieldsFragmentVarsBuilder().build(); + } +} + +class _$GhumanFieldsFragmentVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GhumanFieldsFragmentVars, + _$GhumanFieldsFragmentVars + ]; + @override + final String wireName = 'GhumanFieldsFragmentVars'; + + @override + Iterable serialize( + Serializers serializers, GhumanFieldsFragmentVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GhumanFieldsFragmentVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GhumanFieldsFragmentVarsBuilder().build(); + } +} + +class _$GdroidFieldsFragmentVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GdroidFieldsFragmentVars, + _$GdroidFieldsFragmentVars + ]; + @override + final String wireName = 'GdroidFieldsFragmentVars'; + + @override + Iterable serialize( + Serializers serializers, GdroidFieldsFragmentVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GdroidFieldsFragmentVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GdroidFieldsFragmentVarsBuilder().build(); + } +} + class _$GHeroWithInterfaceSubTypedFragmentsVars extends GHeroWithInterfaceSubTypedFragmentsVars { @override diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/multiple_fragments.var.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/multiple_fragments.var.gql.dart index f30e0a33..ae781cb0 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/multiple_fragments.var.gql.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/multiple_fragments.var.gql.dart @@ -5,8 +5,7 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' - as _i2; -import 'package:gql_exec/value.dart' as _i1; + as _i1; part 'multiple_fragments.var.gql.g.dart'; @@ -18,21 +17,20 @@ abstract class GHeroWith2FragmentsVars [Function(GHeroWith2FragmentsVarsBuilder b) updates]) = _$GHeroWith2FragmentsVars; - _i1.Value? get first; - Map toJson() => (_i2.serializers.serializeWith( + int? get first; + static Serializer get serializer => + _$gHeroWith2FragmentsVarsSerializer; + + Map toJson() => (_i1.serializers.serializeWith( GHeroWith2FragmentsVars.serializer, this, ) as Map); static GHeroWith2FragmentsVars? fromJson(Map json) => - _i2.serializers.deserializeWith( + _i1.serializers.deserializeWith( GHeroWith2FragmentsVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GHeroWith2FragmentsVarsSerializer(); } abstract class GheroNameVars @@ -42,19 +40,18 @@ abstract class GheroNameVars factory GheroNameVars([Function(GheroNameVarsBuilder b) updates]) = _$GheroNameVars; - Map toJson() => (_i2.serializers.serializeWith( + static Serializer get serializer => _$gheroNameVarsSerializer; + + Map toJson() => (_i1.serializers.serializeWith( GheroNameVars.serializer, this, ) as Map); static GheroNameVars? fromJson(Map json) => - _i2.serializers.deserializeWith( + _i1.serializers.deserializeWith( GheroNameVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => GheroNameVarsSerializer(); } abstract class GheroIdVars implements Built { @@ -62,126 +59,16 @@ abstract class GheroIdVars implements Built { factory GheroIdVars([Function(GheroIdVarsBuilder b) updates]) = _$GheroIdVars; - Map toJson() => (_i2.serializers.serializeWith( + static Serializer get serializer => _$gheroIdVarsSerializer; + + Map toJson() => (_i1.serializers.serializeWith( GheroIdVars.serializer, this, ) as Map); static GheroIdVars? fromJson(Map json) => - _i2.serializers.deserializeWith( + _i1.serializers.deserializeWith( GheroIdVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => GheroIdVarsSerializer(); -} - -class GHeroWith2FragmentsVarsSerializer - extends StructuredSerializer { - final String wireName = 'GHeroWith2FragmentsVars'; - - final Iterable types = const [ - GHeroWith2FragmentsVars, - _$GHeroWith2FragmentsVars - ]; - - Iterable serialize( - Serializers serializers, - GHeroWith2FragmentsVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - final _$firstvalue = object.first; - if (_$firstvalue case _i1.PresentValue(value: final _$value)) { - result.add('first'); - result.add( - serializers.serialize(_$value, specifiedType: const FullType(int))); - } - return result; - } - - GHeroWith2FragmentsVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GHeroWith2FragmentsVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'first': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - builder.first = _i1.PresentValue(fieldValue); - break; - } - } - return builder.build(); - } -} - -class GheroNameVarsSerializer extends StructuredSerializer { - final String wireName = 'GheroNameVars'; - - final Iterable types = const [GheroNameVars, _$GheroNameVars]; - - Iterable serialize( - Serializers serializers, - GheroNameVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - return result; - } - - GheroNameVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GheroNameVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) {} - } - return builder.build(); - } -} - -class GheroIdVarsSerializer extends StructuredSerializer { - final String wireName = 'GheroIdVars'; - - final Iterable types = const [GheroIdVars, _$GheroIdVars]; - - Iterable serialize( - Serializers serializers, - GheroIdVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - return result; - } - - GheroIdVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GheroIdVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) {} - } - return builder.build(); - } } diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/multiple_fragments.var.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/multiple_fragments.var.gql.g.dart index bf098c75..6f5e5fb2 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/multiple_fragments.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/multiple_fragments.var.gql.g.dart @@ -6,9 +6,102 @@ part of 'multiple_fragments.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** +Serializer _$gHeroWith2FragmentsVarsSerializer = + new _$GHeroWith2FragmentsVarsSerializer(); +Serializer _$gheroNameVarsSerializer = + new _$GheroNameVarsSerializer(); +Serializer _$gheroIdVarsSerializer = new _$GheroIdVarsSerializer(); + +class _$GHeroWith2FragmentsVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroWith2FragmentsVars, + _$GHeroWith2FragmentsVars + ]; + @override + final String wireName = 'GHeroWith2FragmentsVars'; + + @override + Iterable serialize( + Serializers serializers, GHeroWith2FragmentsVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = []; + Object? value; + value = object.first; + if (value != null) { + result + ..add('first') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + return result; + } + + @override + GHeroWith2FragmentsVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroWith2FragmentsVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'first': + result.first = serializers.deserialize(value, + specifiedType: const FullType(int)) as int?; + break; + } + } + + return result.build(); + } +} + +class _$GheroNameVarsSerializer implements StructuredSerializer { + @override + final Iterable types = const [GheroNameVars, _$GheroNameVars]; + @override + final String wireName = 'GheroNameVars'; + + @override + Iterable serialize(Serializers serializers, GheroNameVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GheroNameVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GheroNameVarsBuilder().build(); + } +} + +class _$GheroIdVarsSerializer implements StructuredSerializer { + @override + final Iterable types = const [GheroIdVars, _$GheroIdVars]; + @override + final String wireName = 'GheroIdVars'; + + @override + Iterable serialize(Serializers serializers, GheroIdVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GheroIdVars deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GheroIdVarsBuilder().build(); + } +} + class _$GHeroWith2FragmentsVars extends GHeroWith2FragmentsVars { @override - final _i1.Value? first; + final int? first; factory _$GHeroWith2FragmentsVars( [void Function(GHeroWith2FragmentsVarsBuilder)? updates]) => @@ -52,9 +145,9 @@ class GHeroWith2FragmentsVarsBuilder Builder { _$GHeroWith2FragmentsVars? _$v; - _i1.Value? _first; - _i1.Value? get first => _$this._first; - set first(_i1.Value? first) => _$this._first = first; + int? _first; + int? get first => _$this._first; + set first(int? first) => _$this._first = first; GHeroWith2FragmentsVarsBuilder(); diff --git a/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.dart b/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.dart index 3705222b..517c2477 100644 --- a/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.dart +++ b/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.dart @@ -7,10 +7,9 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:end_to_end_test/custom_field.dart' as _i2; import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' - as _i3; + as _i1; import 'package:gql_code_builder/src/serializers/default_scalar_serializer.dart' - as _i4; -import 'package:gql_exec/value.dart' as _i1; + as _i3; part 'schema.schema.gql.g.dart'; @@ -56,97 +55,21 @@ abstract class GReviewInput _$GReviewInput; int get stars; - _i1.Value? get commentary; - _i1.Value? get favorite_color; - _i1.Value>? get seenOn; - Map toJson() => (_i3.serializers.serializeWith( + String? get commentary; + GColorInput? get favorite_color; + BuiltList? get seenOn; + static Serializer get serializer => _$gReviewInputSerializer; + + Map toJson() => (_i1.serializers.serializeWith( GReviewInput.serializer, this, ) as Map); static GReviewInput? fromJson(Map json) => - _i3.serializers.deserializeWith( + _i1.serializers.deserializeWith( GReviewInput.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => GReviewInputSerializer(); -} - -class GReviewInputSerializer extends StructuredSerializer { - final String wireName = 'GReviewInput'; - - final Iterable types = const [GReviewInput, _$GReviewInput]; - - Iterable serialize( - Serializers serializers, - GReviewInput object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - result.add('stars'); - result.add(serializers.serialize(object.stars, - specifiedType: const FullType(int))); - final _$commentaryvalue = object.commentary; - if (_$commentaryvalue case _i1.PresentValue(value: final _$value)) { - result.add('commentary'); - result.add(serializers.serialize(_$value, - specifiedType: const FullType(String))); - } - final _$favorite_colorvalue = object.favorite_color; - if (_$favorite_colorvalue case _i1.PresentValue(value: final _$value)) { - result.add('favorite_color'); - result.add(serializers.serialize(_$value, - specifiedType: const FullType(GColorInput))); - } - final _$seenOnvalue = object.seenOn; - if (_$seenOnvalue case _i1.PresentValue(value: final _$value)) { - result.add('seenOn'); - result.add(serializers.serialize(_$value, - specifiedType: const FullType(BuiltList, [FullType(DateTime)]))); - } - return result; - } - - GReviewInput deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GReviewInputBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'stars': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - builder.stars = fieldValue; - break; - case 'commentary': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - builder.commentary = _i1.PresentValue(fieldValue); - break; - case 'favorite_color': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(GColorInput)) as GColorInput; - builder.favorite_color = _i1.PresentValue(fieldValue); - break; - case 'seenOn': - var fieldValue = serializers.deserialize(value, - specifiedType: - const FullType(BuiltList, [FullType(DateTime)])) - as BuiltList; - builder.seenOn = _i1.PresentValue(fieldValue); - break; - } - } - return builder.build(); - } } abstract class GCustomFieldInput @@ -157,74 +80,20 @@ abstract class GCustomFieldInput _$GCustomFieldInput; String get id; - _i1.Value<_i2.CustomField>? get customField; - Map toJson() => (_i3.serializers.serializeWith( + _i2.CustomField? get customField; + static Serializer get serializer => + _$gCustomFieldInputSerializer; + + Map toJson() => (_i1.serializers.serializeWith( GCustomFieldInput.serializer, this, ) as Map); static GCustomFieldInput? fromJson(Map json) => - _i3.serializers.deserializeWith( + _i1.serializers.deserializeWith( GCustomFieldInput.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GCustomFieldInputSerializer(); -} - -class GCustomFieldInputSerializer - extends StructuredSerializer { - final String wireName = 'GCustomFieldInput'; - - final Iterable types = const [GCustomFieldInput, _$GCustomFieldInput]; - - Iterable serialize( - Serializers serializers, - GCustomFieldInput object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - result.add('id'); - result.add(serializers.serialize(object.id, - specifiedType: const FullType(String))); - final _$customFieldvalue = object.customField; - if (_$customFieldvalue case _i1.PresentValue(value: final _$value)) { - result.add('customField'); - result.add(serializers.serialize(_$value, - specifiedType: const FullType(_i2.CustomField))); - } - return result; - } - - GCustomFieldInput deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GCustomFieldInputBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'id': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - builder.id = fieldValue; - break; - case 'customField': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(_i2.CustomField)) - as _i2.CustomField; - builder.customField = _i1.PresentValue(fieldValue); - break; - } - } - return builder.build(); - } } abstract class GColorInput implements Built { @@ -235,75 +104,18 @@ abstract class GColorInput implements Built { int get red; int get green; int get blue; - Map toJson() => (_i3.serializers.serializeWith( + static Serializer get serializer => _$gColorInputSerializer; + + Map toJson() => (_i1.serializers.serializeWith( GColorInput.serializer, this, ) as Map); static GColorInput? fromJson(Map json) => - _i3.serializers.deserializeWith( + _i1.serializers.deserializeWith( GColorInput.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => GColorInputSerializer(); -} - -class GColorInputSerializer extends StructuredSerializer { - final String wireName = 'GColorInput'; - - final Iterable types = const [GColorInput, _$GColorInput]; - - Iterable serialize( - Serializers serializers, - GColorInput object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - result.add('red'); - result.add( - serializers.serialize(object.red, specifiedType: const FullType(int))); - result.add('green'); - result.add(serializers.serialize(object.green, - specifiedType: const FullType(int))); - result.add('blue'); - result.add( - serializers.serialize(object.blue, specifiedType: const FullType(int))); - return result; - } - - GColorInput deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GColorInputBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'red': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - builder.red = fieldValue; - break; - case 'green': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - builder.green = fieldValue; - break; - case 'blue': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(int)) as int; - builder.blue = fieldValue; - break; - } - } - return builder.build(); - } } abstract class GPostLikesInput @@ -314,60 +126,19 @@ abstract class GPostLikesInput _$GPostLikesInput; String get id; - Map toJson() => (_i3.serializers.serializeWith( + static Serializer get serializer => + _$gPostLikesInputSerializer; + + Map toJson() => (_i1.serializers.serializeWith( GPostLikesInput.serializer, this, ) as Map); static GPostLikesInput? fromJson(Map json) => - _i3.serializers.deserializeWith( + _i1.serializers.deserializeWith( GPostLikesInput.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GPostLikesInputSerializer(); -} - -class GPostLikesInputSerializer extends StructuredSerializer { - final String wireName = 'GPostLikesInput'; - - final Iterable types = const [GPostLikesInput, _$GPostLikesInput]; - - Iterable serialize( - Serializers serializers, - GPostLikesInput object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - result.add('id'); - result.add(serializers.serialize(object.id, - specifiedType: const FullType(String))); - return result; - } - - GPostLikesInput deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GPostLikesInputBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'id': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - builder.id = fieldValue; - break; - } - } - return builder.build(); - } } abstract class GPostFavoritesInput @@ -378,64 +149,19 @@ abstract class GPostFavoritesInput [Function(GPostFavoritesInputBuilder b) updates]) = _$GPostFavoritesInput; String get id; - Map toJson() => (_i3.serializers.serializeWith( + static Serializer get serializer => + _$gPostFavoritesInputSerializer; + + Map toJson() => (_i1.serializers.serializeWith( GPostFavoritesInput.serializer, this, ) as Map); static GPostFavoritesInput? fromJson(Map json) => - _i3.serializers.deserializeWith( + _i1.serializers.deserializeWith( GPostFavoritesInput.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GPostFavoritesInputSerializer(); -} - -class GPostFavoritesInputSerializer - extends StructuredSerializer { - final String wireName = 'GPostFavoritesInput'; - - final Iterable types = const [ - GPostFavoritesInput, - _$GPostFavoritesInput - ]; - - Iterable serialize( - Serializers serializers, - GPostFavoritesInput object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - result.add('id'); - result.add(serializers.serialize(object.id, - specifiedType: const FullType(String))); - return result; - } - - GPostFavoritesInput deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GPostFavoritesInputBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'id': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - builder.id = fieldValue; - break; - } - } - return builder.build(); - } } abstract class GISODate implements Built { @@ -447,7 +173,7 @@ abstract class GISODate implements Built { String get value; @BuiltValueSerializer(custom: true) static Serializer get serializer => - _i4.DefaultScalarSerializer( + _i3.DefaultScalarSerializer( (Object serialized) => GISODate((serialized as String?))); } @@ -459,7 +185,7 @@ abstract class GJson implements Built { String get value; @BuiltValueSerializer(custom: true) - static Serializer get serializer => _i4.DefaultScalarSerializer( + static Serializer get serializer => _i3.DefaultScalarSerializer( (Object serialized) => GJson((serialized as String?))); } diff --git a/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.g.dart b/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.g.dart index 0b62d7aa..ec9b81b6 100644 --- a/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.g.dart +++ b/codegen/end_to_end_test/lib/graphql/__generated__/schema.schema.gql.g.dart @@ -52,6 +52,15 @@ final BuiltSet _$gLengthUnitValues = Serializer _$gEpisodeSerializer = new _$GEpisodeSerializer(); Serializer _$gLengthUnitSerializer = new _$GLengthUnitSerializer(); +Serializer _$gReviewInputSerializer = + new _$GReviewInputSerializer(); +Serializer _$gCustomFieldInputSerializer = + new _$GCustomFieldInputSerializer(); +Serializer _$gColorInputSerializer = new _$GColorInputSerializer(); +Serializer _$gPostLikesInputSerializer = + new _$GPostLikesInputSerializer(); +Serializer _$gPostFavoritesInputSerializer = + new _$GPostFavoritesInputSerializer(); class _$GEpisodeSerializer implements PrimitiveSerializer { @override @@ -95,15 +104,281 @@ class _$GLengthUnitSerializer implements PrimitiveSerializer { _fromWire[serialized] ?? (serialized is String ? serialized : '')); } +class _$GReviewInputSerializer implements StructuredSerializer { + @override + final Iterable types = const [GReviewInput, _$GReviewInput]; + @override + final String wireName = 'GReviewInput'; + + @override + Iterable serialize(Serializers serializers, GReviewInput object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'stars', + serializers.serialize(object.stars, specifiedType: const FullType(int)), + ]; + Object? value; + value = object.commentary; + if (value != null) { + result + ..add('commentary') + ..add(serializers.serialize(value, + specifiedType: const FullType(String))); + } + value = object.favorite_color; + if (value != null) { + result + ..add('favorite_color') + ..add(serializers.serialize(value, + specifiedType: const FullType(GColorInput))); + } + value = object.seenOn; + if (value != null) { + result + ..add('seenOn') + ..add(serializers.serialize(value, + specifiedType: const FullType( + BuiltList, const [const FullType.nullable(DateTime)]))); + } + return result; + } + + @override + GReviewInput deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GReviewInputBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'stars': + result.stars = serializers.deserialize(value, + specifiedType: const FullType(int))! as int; + break; + case 'commentary': + result.commentary = serializers.deserialize(value, + specifiedType: const FullType(String)) as String?; + break; + case 'favorite_color': + result.favorite_color.replace(serializers.deserialize(value, + specifiedType: const FullType(GColorInput))! as GColorInput); + break; + case 'seenOn': + result.seenOn.replace(serializers.deserialize(value, + specifiedType: const FullType( + BuiltList, const [const FullType.nullable(DateTime)]))! + as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$GCustomFieldInputSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GCustomFieldInput, _$GCustomFieldInput]; + @override + final String wireName = 'GCustomFieldInput'; + + @override + Iterable serialize(Serializers serializers, GCustomFieldInput object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.customField; + if (value != null) { + result + ..add('customField') + ..add(serializers.serialize(value, + specifiedType: const FullType(_i2.CustomField))); + } + return result; + } + + @override + GCustomFieldInput deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GCustomFieldInputBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'customField': + result.customField = serializers.deserialize(value, + specifiedType: const FullType(_i2.CustomField)) + as _i2.CustomField?; + break; + } + } + + return result.build(); + } +} + +class _$GColorInputSerializer implements StructuredSerializer { + @override + final Iterable types = const [GColorInput, _$GColorInput]; + @override + final String wireName = 'GColorInput'; + + @override + Iterable serialize(Serializers serializers, GColorInput object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'red', + serializers.serialize(object.red, specifiedType: const FullType(int)), + 'green', + serializers.serialize(object.green, specifiedType: const FullType(int)), + 'blue', + serializers.serialize(object.blue, specifiedType: const FullType(int)), + ]; + + return result; + } + + @override + GColorInput deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GColorInputBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'red': + result.red = serializers.deserialize(value, + specifiedType: const FullType(int))! as int; + break; + case 'green': + result.green = serializers.deserialize(value, + specifiedType: const FullType(int))! as int; + break; + case 'blue': + result.blue = serializers.deserialize(value, + specifiedType: const FullType(int))! as int; + break; + } + } + + return result.build(); + } +} + +class _$GPostLikesInputSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GPostLikesInput, _$GPostLikesInput]; + @override + final String wireName = 'GPostLikesInput'; + + @override + Iterable serialize(Serializers serializers, GPostLikesInput object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GPostLikesInput deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostLikesInputBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GPostFavoritesInputSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GPostFavoritesInput, + _$GPostFavoritesInput + ]; + @override + final String wireName = 'GPostFavoritesInput'; + + @override + Iterable serialize( + Serializers serializers, GPostFavoritesInput object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GPostFavoritesInput deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostFavoritesInputBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + class _$GReviewInput extends GReviewInput { @override final int stars; @override - final _i1.Value? commentary; + final String? commentary; @override - final _i1.Value? favorite_color; + final GColorInput? favorite_color; @override - final _i1.Value>? seenOn; + final BuiltList? seenOn; factory _$GReviewInput([void Function(GReviewInputBuilder)? updates]) => (new GReviewInputBuilder()..update(updates))._build(); @@ -161,20 +436,20 @@ class GReviewInputBuilder int? get stars => _$this._stars; set stars(int? stars) => _$this._stars = stars; - _i1.Value? _commentary; - _i1.Value? get commentary => _$this._commentary; - set commentary(_i1.Value? commentary) => - _$this._commentary = commentary; + String? _commentary; + String? get commentary => _$this._commentary; + set commentary(String? commentary) => _$this._commentary = commentary; - _i1.Value? _favorite_color; - _i1.Value? get favorite_color => _$this._favorite_color; - set favorite_color(_i1.Value? favorite_color) => + GColorInputBuilder? _favorite_color; + GColorInputBuilder get favorite_color => + _$this._favorite_color ??= new GColorInputBuilder(); + set favorite_color(GColorInputBuilder? favorite_color) => _$this._favorite_color = favorite_color; - _i1.Value>? _seenOn; - _i1.Value>? get seenOn => _$this._seenOn; - set seenOn(_i1.Value>? seenOn) => - _$this._seenOn = seenOn; + ListBuilder? _seenOn; + ListBuilder get seenOn => + _$this._seenOn ??= new ListBuilder(); + set seenOn(ListBuilder? seenOn) => _$this._seenOn = seenOn; GReviewInputBuilder(); @@ -183,8 +458,8 @@ class GReviewInputBuilder if ($v != null) { _stars = $v.stars; _commentary = $v.commentary; - _favorite_color = $v.favorite_color; - _seenOn = $v.seenOn; + _favorite_color = $v.favorite_color?.toBuilder(); + _seenOn = $v.seenOn?.toBuilder(); _$v = null; } return this; @@ -205,13 +480,28 @@ class GReviewInputBuilder GReviewInput build() => _build(); _$GReviewInput _build() { - final _$result = _$v ?? - new _$GReviewInput._( - stars: BuiltValueNullFieldError.checkNotNull( - stars, r'GReviewInput', 'stars'), - commentary: commentary, - favorite_color: favorite_color, - seenOn: seenOn); + _$GReviewInput _$result; + try { + _$result = _$v ?? + new _$GReviewInput._( + stars: BuiltValueNullFieldError.checkNotNull( + stars, r'GReviewInput', 'stars'), + commentary: commentary, + favorite_color: _favorite_color?.build(), + seenOn: _seenOn?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'favorite_color'; + _favorite_color?.build(); + _$failedField = 'seenOn'; + _seenOn?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GReviewInput', _$failedField, e.toString()); + } + rethrow; + } replace(_$result); return _$result; } @@ -221,7 +511,7 @@ class _$GCustomFieldInput extends GCustomFieldInput { @override final String id; @override - final _i1.Value<_i2.CustomField>? customField; + final _i2.CustomField? customField; factory _$GCustomFieldInput( [void Function(GCustomFieldInputBuilder)? updates]) => @@ -273,9 +563,9 @@ class GCustomFieldInputBuilder String? get id => _$this._id; set id(String? id) => _$this._id = id; - _i1.Value<_i2.CustomField>? _customField; - _i1.Value<_i2.CustomField>? get customField => _$this._customField; - set customField(_i1.Value<_i2.CustomField>? customField) => + _i2.CustomField? _customField; + _i2.CustomField? get customField => _$this._customField; + set customField(_i2.CustomField? customField) => _$this._customField = customField; GCustomFieldInputBuilder(); diff --git a/codegen/end_to_end_test/lib/graphql/__generated__/serializers.gql.g.dart b/codegen/end_to_end_test/lib/graphql/__generated__/serializers.gql.g.dart index 86cbb01f..6e8208e2 100644 --- a/codegen/end_to_end_test/lib/graphql/__generated__/serializers.gql.g.dart +++ b/codegen/end_to_end_test/lib/graphql/__generated__/serializers.gql.g.dart @@ -113,6 +113,9 @@ Serializers _$serializers = (new Serializers().toBuilder() ..addBuilderFactory( const FullType(BuiltList, const [const FullType(CustomField)]), () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType.nullable(DateTime)]), + () => new ListBuilder()) ..addBuilderFactory( const FullType(BuiltList, const [const FullType.nullable(GEpisode)]), () => new ListBuilder()) diff --git a/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.dart b/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.dart index 3c158682..4946036f 100644 --- a/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.dart +++ b/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.dart @@ -19,6 +19,9 @@ abstract class GHeroForEpisodeVars [Function(GHeroForEpisodeVarsBuilder b) updates]) = _$GHeroForEpisodeVars; _i1.GEpisode get ep; + static Serializer get serializer => + _$gHeroForEpisodeVarsSerializer; + Map toJson() => (_i2.serializers.serializeWith( GHeroForEpisodeVars.serializer, this, @@ -29,10 +32,6 @@ abstract class GHeroForEpisodeVars GHeroForEpisodeVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GHeroForEpisodeVarsSerializer(); } abstract class GDroidFragmentVars @@ -42,6 +41,9 @@ abstract class GDroidFragmentVars factory GDroidFragmentVars([Function(GDroidFragmentVarsBuilder b) updates]) = _$GDroidFragmentVars; + static Serializer get serializer => + _$gDroidFragmentVarsSerializer; + Map toJson() => (_i2.serializers.serializeWith( GDroidFragmentVars.serializer, this, @@ -52,84 +54,4 @@ abstract class GDroidFragmentVars GDroidFragmentVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GDroidFragmentVarsSerializer(); -} - -class GHeroForEpisodeVarsSerializer - extends StructuredSerializer { - final String wireName = 'GHeroForEpisodeVars'; - - final Iterable types = const [ - GHeroForEpisodeVars, - _$GHeroForEpisodeVars - ]; - - Iterable serialize( - Serializers serializers, - GHeroForEpisodeVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - result.add('ep'); - result.add(serializers.serialize(object.ep, - specifiedType: const FullType(_i1.GEpisode))); - return result; - } - - GHeroForEpisodeVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GHeroForEpisodeVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'ep': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; - builder.ep = fieldValue; - break; - } - } - return builder.build(); - } -} - -class GDroidFragmentVarsSerializer - extends StructuredSerializer { - final String wireName = 'GDroidFragmentVars'; - - final Iterable types = const [GDroidFragmentVars, _$GDroidFragmentVars]; - - Iterable serialize( - Serializers serializers, - GDroidFragmentVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - return result; - } - - GDroidFragmentVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GDroidFragmentVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) {} - } - return builder.build(); - } } diff --git a/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.g.dart b/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.g.dart index 5ff1690c..4de27c1d 100644 --- a/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/interfaces/__generated__/hero_for_episode.var.gql.g.dart @@ -6,6 +6,79 @@ part of 'hero_for_episode.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** +Serializer _$gHeroForEpisodeVarsSerializer = + new _$GHeroForEpisodeVarsSerializer(); +Serializer _$gDroidFragmentVarsSerializer = + new _$GDroidFragmentVarsSerializer(); + +class _$GHeroForEpisodeVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroForEpisodeVars, + _$GHeroForEpisodeVars + ]; + @override + final String wireName = 'GHeroForEpisodeVars'; + + @override + Iterable serialize( + Serializers serializers, GHeroForEpisodeVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'ep', + serializers.serialize(object.ep, + specifiedType: const FullType(_i1.GEpisode)), + ]; + + return result; + } + + @override + GHeroForEpisodeVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroForEpisodeVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'ep': + result.ep = serializers.deserialize(value, + specifiedType: const FullType(_i1.GEpisode))! as _i1.GEpisode; + break; + } + } + + return result.build(); + } +} + +class _$GDroidFragmentVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GDroidFragmentVars, _$GDroidFragmentVars]; + @override + final String wireName = 'GDroidFragmentVars'; + + @override + Iterable serialize( + Serializers serializers, GDroidFragmentVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GDroidFragmentVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GDroidFragmentVarsBuilder().build(); + } +} + class _$GHeroForEpisodeVars extends GHeroForEpisodeVars { @override final _i1.GEpisode ep; diff --git a/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.dart b/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.dart index 8f62d109..a93cb2fb 100644 --- a/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.dart +++ b/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.dart @@ -16,6 +16,9 @@ abstract class GHeroNoVarsVars factory GHeroNoVarsVars([Function(GHeroNoVarsVarsBuilder b) updates]) = _$GHeroNoVarsVars; + static Serializer get serializer => + _$gHeroNoVarsVarsSerializer; + Map toJson() => (_i1.serializers.serializeWith( GHeroNoVarsVars.serializer, this, @@ -26,39 +29,4 @@ abstract class GHeroNoVarsVars GHeroNoVarsVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GHeroNoVarsVarsSerializer(); -} - -class GHeroNoVarsVarsSerializer extends StructuredSerializer { - final String wireName = 'GHeroNoVarsVars'; - - final Iterable types = const [GHeroNoVarsVars, _$GHeroNoVarsVars]; - - Iterable serialize( - Serializers serializers, - GHeroNoVarsVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - return result; - } - - GHeroNoVarsVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GHeroNoVarsVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) {} - } - return builder.build(); - } } diff --git a/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.g.dart b/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.g.dart index f5ef2947..c98b3a7e 100644 --- a/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/no_vars/__generated__/hero_no_vars.var.gql.g.dart @@ -6,6 +6,30 @@ part of 'hero_no_vars.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** +Serializer _$gHeroNoVarsVarsSerializer = + new _$GHeroNoVarsVarsSerializer(); + +class _$GHeroNoVarsVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GHeroNoVarsVars, _$GHeroNoVarsVars]; + @override + final String wireName = 'GHeroNoVarsVars'; + + @override + Iterable serialize(Serializers serializers, GHeroNoVarsVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GHeroNoVarsVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GHeroNoVarsVarsBuilder().build(); + } +} + class _$GHeroNoVarsVars extends GHeroNoVarsVars { factory _$GHeroNoVarsVars([void Function(GHeroNoVarsVarsBuilder)? updates]) => (new GHeroNoVarsVarsBuilder()..update(updates))._build(); diff --git a/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.dart b/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.dart index 2962a50e..1e6ee798 100644 --- a/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.dart +++ b/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.dart @@ -5,10 +5,9 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart' - as _i2; + as _i1; import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' - as _i3; -import 'package:gql_exec/value.dart' as _i1; + as _i2; part 'review_with_date.var.gql.g.dart'; @@ -19,88 +18,20 @@ abstract class GReviewWithDateVars factory GReviewWithDateVars( [Function(GReviewWithDateVarsBuilder b) updates]) = _$GReviewWithDateVars; - _i1.Value<_i2.GEpisode>? get episode; - _i2.GReviewInput get review; - _i1.Value? get createdAt; - Map toJson() => (_i3.serializers.serializeWith( + _i1.GEpisode? get episode; + _i1.GReviewInput get review; + DateTime? get createdAt; + static Serializer get serializer => + _$gReviewWithDateVarsSerializer; + + Map toJson() => (_i2.serializers.serializeWith( GReviewWithDateVars.serializer, this, ) as Map); static GReviewWithDateVars? fromJson(Map json) => - _i3.serializers.deserializeWith( + _i2.serializers.deserializeWith( GReviewWithDateVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GReviewWithDateVarsSerializer(); -} - -class GReviewWithDateVarsSerializer - extends StructuredSerializer { - final String wireName = 'GReviewWithDateVars'; - - final Iterable types = const [ - GReviewWithDateVars, - _$GReviewWithDateVars - ]; - - Iterable serialize( - Serializers serializers, - GReviewWithDateVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - final _$episodevalue = object.episode; - if (_$episodevalue case _i1.PresentValue(value: final _$value)) { - result.add('episode'); - result.add(serializers.serialize(_$value, - specifiedType: const FullType(_i2.GEpisode))); - } - result.add('review'); - result.add(serializers.serialize(object.review, - specifiedType: const FullType(_i2.GReviewInput))); - final _$createdAtvalue = object.createdAt; - if (_$createdAtvalue case _i1.PresentValue(value: final _$value)) { - result.add('createdAt'); - result.add(serializers.serialize(_$value, - specifiedType: const FullType(DateTime))); - } - return result; - } - - GReviewWithDateVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GReviewWithDateVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'episode': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(_i2.GEpisode)) as _i2.GEpisode; - builder.episode = _i1.PresentValue(fieldValue); - break; - case 'review': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(_i2.GReviewInput)) - as _i2.GReviewInput; - builder.review.replace(fieldValue); - break; - case 'createdAt': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(DateTime)) as DateTime; - builder.createdAt = _i1.PresentValue(fieldValue); - break; - } - } - return builder.build(); - } } diff --git a/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.g.dart b/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.g.dart index 6ae4009b..7663a833 100644 --- a/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/scalars/__generated__/review_with_date.var.gql.g.dart @@ -6,13 +6,85 @@ part of 'review_with_date.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** +Serializer _$gReviewWithDateVarsSerializer = + new _$GReviewWithDateVarsSerializer(); + +class _$GReviewWithDateVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GReviewWithDateVars, + _$GReviewWithDateVars + ]; + @override + final String wireName = 'GReviewWithDateVars'; + + @override + Iterable serialize( + Serializers serializers, GReviewWithDateVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'review', + serializers.serialize(object.review, + specifiedType: const FullType(_i1.GReviewInput)), + ]; + Object? value; + value = object.episode; + if (value != null) { + result + ..add('episode') + ..add(serializers.serialize(value, + specifiedType: const FullType(_i1.GEpisode))); + } + value = object.createdAt; + if (value != null) { + result + ..add('createdAt') + ..add(serializers.serialize(value, + specifiedType: const FullType(DateTime))); + } + return result; + } + + @override + GReviewWithDateVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GReviewWithDateVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'episode': + result.episode = serializers.deserialize(value, + specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode?; + break; + case 'review': + result.review.replace(serializers.deserialize(value, + specifiedType: const FullType(_i1.GReviewInput))! + as _i1.GReviewInput); + break; + case 'createdAt': + result.createdAt = serializers.deserialize(value, + specifiedType: const FullType(DateTime)) as DateTime?; + break; + } + } + + return result.build(); + } +} + class _$GReviewWithDateVars extends GReviewWithDateVars { @override - final _i1.Value<_i2.GEpisode>? episode; + final _i1.GEpisode? episode; @override - final _i2.GReviewInput review; + final _i1.GReviewInput review; @override - final _i1.Value? createdAt; + final DateTime? createdAt; factory _$GReviewWithDateVars( [void Function(GReviewWithDateVarsBuilder)? updates]) => @@ -66,19 +138,18 @@ class GReviewWithDateVarsBuilder implements Builder { _$GReviewWithDateVars? _$v; - _i1.Value<_i2.GEpisode>? _episode; - _i1.Value<_i2.GEpisode>? get episode => _$this._episode; - set episode(_i1.Value<_i2.GEpisode>? episode) => _$this._episode = episode; + _i1.GEpisode? _episode; + _i1.GEpisode? get episode => _$this._episode; + set episode(_i1.GEpisode? episode) => _$this._episode = episode; - _i2.GReviewInputBuilder? _review; - _i2.GReviewInputBuilder get review => - _$this._review ??= new _i2.GReviewInputBuilder(); - set review(_i2.GReviewInputBuilder? review) => _$this._review = review; + _i1.GReviewInputBuilder? _review; + _i1.GReviewInputBuilder get review => + _$this._review ??= new _i1.GReviewInputBuilder(); + set review(_i1.GReviewInputBuilder? review) => _$this._review = review; - _i1.Value? _createdAt; - _i1.Value? get createdAt => _$this._createdAt; - set createdAt(_i1.Value? createdAt) => - _$this._createdAt = createdAt; + DateTime? _createdAt; + DateTime? get createdAt => _$this._createdAt; + set createdAt(DateTime? createdAt) => _$this._createdAt = createdAt; GReviewWithDateVarsBuilder(); diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.dart index b8bd9b7a..c30c6d17 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.dart @@ -20,6 +20,9 @@ abstract class GCreateCustomFieldVars _$GCreateCustomFieldVars; _i1.GCustomFieldInput get input; + static Serializer get serializer => + _$gCreateCustomFieldVarsSerializer; + Map toJson() => (_i2.serializers.serializeWith( GCreateCustomFieldVars.serializer, this, @@ -30,53 +33,4 @@ abstract class GCreateCustomFieldVars GCreateCustomFieldVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GCreateCustomFieldVarsSerializer(); -} - -class GCreateCustomFieldVarsSerializer - extends StructuredSerializer { - final String wireName = 'GCreateCustomFieldVars'; - - final Iterable types = const [ - GCreateCustomFieldVars, - _$GCreateCustomFieldVars - ]; - - Iterable serialize( - Serializers serializers, - GCreateCustomFieldVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - result.add('input'); - result.add(serializers.serialize(object.input, - specifiedType: const FullType(_i1.GCustomFieldInput))); - return result; - } - - GCreateCustomFieldVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GCreateCustomFieldVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'input': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(_i1.GCustomFieldInput)) - as _i1.GCustomFieldInput; - builder.input.replace(fieldValue); - break; - } - } - return builder.build(); - } } diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.g.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.g.dart index a4582afc..8c22a2e0 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_custom_field.var.gql.g.dart @@ -6,6 +6,56 @@ part of 'create_custom_field.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** +Serializer _$gCreateCustomFieldVarsSerializer = + new _$GCreateCustomFieldVarsSerializer(); + +class _$GCreateCustomFieldVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GCreateCustomFieldVars, + _$GCreateCustomFieldVars + ]; + @override + final String wireName = 'GCreateCustomFieldVars'; + + @override + Iterable serialize( + Serializers serializers, GCreateCustomFieldVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'input', + serializers.serialize(object.input, + specifiedType: const FullType(_i1.GCustomFieldInput)), + ]; + + return result; + } + + @override + GCreateCustomFieldVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GCreateCustomFieldVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'input': + result.input.replace(serializers.deserialize(value, + specifiedType: const FullType(_i1.GCustomFieldInput))! + as _i1.GCustomFieldInput); + break; + } + } + + return result.build(); + } +} + class _$GCreateCustomFieldVars extends GCreateCustomFieldVars { @override final _i1.GCustomFieldInput input; diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.dart index 25e1e113..b49c98ae 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.dart @@ -5,10 +5,9 @@ import 'package:built_value/built_value.dart'; import 'package:built_value/serializer.dart'; import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart' - as _i2; + as _i1; import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' - as _i3; -import 'package:gql_exec/value.dart' as _i1; + as _i2; part 'create_review.var.gql.g.dart'; @@ -19,73 +18,19 @@ abstract class GCreateReviewVars factory GCreateReviewVars([Function(GCreateReviewVarsBuilder b) updates]) = _$GCreateReviewVars; - _i1.Value<_i2.GEpisode>? get episode; - _i2.GReviewInput get review; - Map toJson() => (_i3.serializers.serializeWith( + _i1.GEpisode? get episode; + _i1.GReviewInput get review; + static Serializer get serializer => + _$gCreateReviewVarsSerializer; + + Map toJson() => (_i2.serializers.serializeWith( GCreateReviewVars.serializer, this, ) as Map); static GCreateReviewVars? fromJson(Map json) => - _i3.serializers.deserializeWith( + _i2.serializers.deserializeWith( GCreateReviewVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GCreateReviewVarsSerializer(); -} - -class GCreateReviewVarsSerializer - extends StructuredSerializer { - final String wireName = 'GCreateReviewVars'; - - final Iterable types = const [GCreateReviewVars, _$GCreateReviewVars]; - - Iterable serialize( - Serializers serializers, - GCreateReviewVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - final _$episodevalue = object.episode; - if (_$episodevalue case _i1.PresentValue(value: final _$value)) { - result.add('episode'); - result.add(serializers.serialize(_$value, - specifiedType: const FullType(_i2.GEpisode))); - } - result.add('review'); - result.add(serializers.serialize(object.review, - specifiedType: const FullType(_i2.GReviewInput))); - return result; - } - - GCreateReviewVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GCreateReviewVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'episode': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(_i2.GEpisode)) as _i2.GEpisode; - builder.episode = _i1.PresentValue(fieldValue); - break; - case 'review': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(_i2.GReviewInput)) - as _i2.GReviewInput; - builder.review.replace(fieldValue); - break; - } - } - return builder.build(); - } } diff --git a/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.g.dart b/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.g.dart index e1382e95..1077ab97 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/create_review.var.gql.g.dart @@ -6,11 +6,68 @@ part of 'create_review.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** +Serializer _$gCreateReviewVarsSerializer = + new _$GCreateReviewVarsSerializer(); + +class _$GCreateReviewVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GCreateReviewVars, _$GCreateReviewVars]; + @override + final String wireName = 'GCreateReviewVars'; + + @override + Iterable serialize(Serializers serializers, GCreateReviewVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'review', + serializers.serialize(object.review, + specifiedType: const FullType(_i1.GReviewInput)), + ]; + Object? value; + value = object.episode; + if (value != null) { + result + ..add('episode') + ..add(serializers.serialize(value, + specifiedType: const FullType(_i1.GEpisode))); + } + return result; + } + + @override + GCreateReviewVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GCreateReviewVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'episode': + result.episode = serializers.deserialize(value, + specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode?; + break; + case 'review': + result.review.replace(serializers.deserialize(value, + specifiedType: const FullType(_i1.GReviewInput))! + as _i1.GReviewInput); + break; + } + } + + return result.build(); + } +} + class _$GCreateReviewVars extends GCreateReviewVars { @override - final _i1.Value<_i2.GEpisode>? episode; + final _i1.GEpisode? episode; @override - final _i2.GReviewInput review; + final _i1.GReviewInput review; factory _$GCreateReviewVars( [void Function(GCreateReviewVarsBuilder)? updates]) => @@ -59,14 +116,14 @@ class GCreateReviewVarsBuilder implements Builder { _$GCreateReviewVars? _$v; - _i1.Value<_i2.GEpisode>? _episode; - _i1.Value<_i2.GEpisode>? get episode => _$this._episode; - set episode(_i1.Value<_i2.GEpisode>? episode) => _$this._episode = episode; + _i1.GEpisode? _episode; + _i1.GEpisode? get episode => _$this._episode; + set episode(_i1.GEpisode? episode) => _$this._episode = episode; - _i2.GReviewInputBuilder? _review; - _i2.GReviewInputBuilder get review => - _$this._review ??= new _i2.GReviewInputBuilder(); - set review(_i2.GReviewInputBuilder? review) => _$this._review = review; + _i1.GReviewInputBuilder? _review; + _i1.GReviewInputBuilder get review => + _$this._review ??= new _i1.GReviewInputBuilder(); + set review(_i1.GReviewInputBuilder? review) => _$this._review = review; GCreateReviewVarsBuilder(); diff --git a/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.dart b/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.dart index 44c881e6..32d9434a 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.dart @@ -17,6 +17,9 @@ abstract class GHumanWithArgsVars _$GHumanWithArgsVars; String get id; + static Serializer get serializer => + _$gHumanWithArgsVarsSerializer; + Map toJson() => (_i1.serializers.serializeWith( GHumanWithArgsVars.serializer, this, @@ -27,49 +30,4 @@ abstract class GHumanWithArgsVars GHumanWithArgsVars.serializer, json, ); - - @BuiltValueSerializer(custom: true, serializeNulls: true) - static Serializer get serializer => - GHumanWithArgsVarsSerializer(); -} - -class GHumanWithArgsVarsSerializer - extends StructuredSerializer { - final String wireName = 'GHumanWithArgsVars'; - - final Iterable types = const [GHumanWithArgsVars, _$GHumanWithArgsVars]; - - Iterable serialize( - Serializers serializers, - GHumanWithArgsVars object, { - FullType specifiedType = FullType.unspecified, - }) { - final result = []; - result.add('id'); - result.add(serializers.serialize(object.id, - specifiedType: const FullType(String))); - return result; - } - - GHumanWithArgsVars deserialize( - Serializers serializers, - Iterable serialized, { - FullType specifiedType = FullType.unspecified, - }) { - final builder = GHumanWithArgsVarsBuilder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - case 'id': - var fieldValue = serializers.deserialize(value, - specifiedType: const FullType(String)) as String; - builder.id = fieldValue; - break; - } - } - return builder.build(); - } } diff --git a/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.g.dart b/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.g.dart index 907174cc..af283a73 100644 --- a/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.g.dart +++ b/codegen/end_to_end_test/lib/variables/__generated__/human_with_args.var.gql.g.dart @@ -6,6 +6,51 @@ part of 'human_with_args.var.gql.dart'; // BuiltValueGenerator // ************************************************************************** +Serializer _$gHumanWithArgsVarsSerializer = + new _$GHumanWithArgsVarsSerializer(); + +class _$GHumanWithArgsVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GHumanWithArgsVars, _$GHumanWithArgsVars]; + @override + final String wireName = 'GHumanWithArgsVars'; + + @override + Iterable serialize( + Serializers serializers, GHumanWithArgsVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GHumanWithArgsVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHumanWithArgsVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + class _$GHumanWithArgsVars extends GHumanWithArgsVars { @override final String id; diff --git a/codegen/end_to_end_test/pubspec.yaml b/codegen/end_to_end_test/pubspec.yaml index ad43d3cd..a44d3a61 100644 --- a/codegen/end_to_end_test/pubspec.yaml +++ b/codegen/end_to_end_test/pubspec.yaml @@ -1,7 +1,7 @@ name: end_to_end_test version: 0.0.1 publish_to: none -description: Tests, not for publishing.\n +description: Tests, not for publishing. Uses the original version of codegen without tristate optionals. repository: https://github.com/gql-dart/gql environment: sdk: '>=3.0.0 <4.0.0' diff --git a/codegen/end_to_end_test/test/operation/variables_test.dart b/codegen/end_to_end_test/test/operation/variables_test.dart index e6eef647..f7955176 100644 --- a/codegen/end_to_end_test/test/operation/variables_test.dart +++ b/codegen/end_to_end_test/test/operation/variables_test.dart @@ -1,4 +1,3 @@ -import 'package:gql_exec/value.dart'; import "package:test/test.dart"; import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart'; @@ -20,13 +19,12 @@ void main() { group("Complex Args", () { final args = GCreateReviewVars((b) => b - ..episode = Value.present(GEpisode.EMPIRE) + ..episode = GEpisode.EMPIRE ..review.stars = 5 - ..review.commentary = Value.present("this was amazing!!!") - ..review.favorite_color = Value.present(GColorInput((b) => b - ..blue = 255 - ..green = 120 - ..red = 80))); + ..review.commentary = ("this was amazing!!!") + ..review.favorite_color.blue = 255 + ..review.favorite_color.green = 120 + ..review.favorite_color.red = 80); final json = { "episode": "EMPIRE", diff --git a/codegen/end_to_end_test/test/schema/input_test.dart b/codegen/end_to_end_test/test/schema/input_test.dart index b73a2ac2..a4cc444e 100644 --- a/codegen/end_to_end_test/test/schema/input_test.dart +++ b/codegen/end_to_end_test/test/schema/input_test.dart @@ -1,4 +1,3 @@ -import 'package:gql_exec/value.dart'; import "package:test/test.dart"; import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart'; @@ -8,20 +7,18 @@ void main() { test('can be instantiated', () { GReviewInput((b) => b ..stars = 4 - ..commentary = Value.present("This was a great movie!") - ..favorite_color = Value.present(GColorInput((b) => b - ..red = 225 - ..blue = 255 - ..green = 123))); + ..commentary = ("This was a great movie!") + ..favorite_color.blue = 255 + ..favorite_color.green = 123 + ..favorite_color.red = 225); }); test('can be serialized and deserialized', () { final input = GReviewInput((b) => b ..stars = 4 - ..favorite_color = Value.present(GColorInput((b) => b - ..red = 225 - ..blue = 255 - ..green = 123))); + ..favorite_color.red = 225 + ..favorite_color.blue = 255 + ..favorite_color.green = 123); final json = { "stars": 4, "favorite_color": { diff --git a/codegen/end_to_end_test/test/schema/scalars_test.dart b/codegen/end_to_end_test/test/schema/scalars_test.dart index 1bd5f984..97ef16ec 100644 --- a/codegen/end_to_end_test/test/schema/scalars_test.dart +++ b/codegen/end_to_end_test/test/schema/scalars_test.dart @@ -1,5 +1,3 @@ -import 'package:built_collection/built_collection.dart'; -import 'package:gql_exec/value.dart'; import "package:test/test.dart"; import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart'; @@ -59,12 +57,9 @@ void main() { group("Custom scalars in input types", () { final input = GReviewInput((b) => b ..stars = 4 - ..seenOn = Value.present( - BuiltList([DateTime.fromMillisecondsSinceEpoch(1591892597000)]), - )); + ..seenOn.add(DateTime.fromMillisecondsSinceEpoch(1591892597000))); test('correctly overrides scalars in input types', () { - expect((input.seenOn! as PresentValue).value!.first, - TypeMatcher()); + expect((input.seenOn!).first, TypeMatcher()); }); test('can be serialized and deserialized with custom serializer', () { @@ -81,12 +76,11 @@ void main() { final vars = GReviewWithDateVars( (b) => b ..review.stars = 4 - ..createdAt = - Value.present(DateTime.fromMillisecondsSinceEpoch(1591892597000)), + ..createdAt = DateTime.fromMillisecondsSinceEpoch(1591892597000), ); test('correctly overrides scalars in variable types', () { - expect((vars.createdAt! as PresentValue).value, TypeMatcher()); + expect((vars.createdAt), TypeMatcher()); }); test('can be serialized and deserialized with custom serializer', () { diff --git a/codegen/end_to_end_test_tristate/.gitignore b/codegen/end_to_end_test_tristate/.gitignore new file mode 100644 index 00000000..50602ac6 --- /dev/null +++ b/codegen/end_to_end_test_tristate/.gitignore @@ -0,0 +1,11 @@ +# Files and directories created by pub +.dart_tool/ +.packages +# Remove the following pattern if you wish to check in your lock file +pubspec.lock + +# Conventional directory for build outputs +build/ + +# Directory created by dartdoc +doc/api/ diff --git a/codegen/end_to_end_test_tristate/analysis_options.yaml b/codegen/end_to_end_test_tristate/analysis_options.yaml new file mode 100644 index 00000000..5eb5e32a --- /dev/null +++ b/codegen/end_to_end_test_tristate/analysis_options.yaml @@ -0,0 +1,7 @@ + +analyzer: + errors: + # TODO: remove this once the wrongly generated @override + # for toJson() in some cases is fixed + override_on_non_overriding_member: ignore + diff --git a/codegen/end_to_end_test_tristate/build.yaml b/codegen/end_to_end_test_tristate/build.yaml new file mode 100644 index 00000000..ba605c1e --- /dev/null +++ b/codegen/end_to_end_test_tristate/build.yaml @@ -0,0 +1,60 @@ +targets: + $default: + builders: + gql_build|ast_builder: + enabled: true + gql_build|req_builder: + enabled: true + options: + schema: end_to_end_test_tristate|lib/graphql/schema.graphql + gql_build|serializer_builder: + enabled: true + options: + schema: end_to_end_test_tristate|lib/graphql/schema.graphql + custom_serializers: + - import: 'package:end_to_end_test_tristate/date_serializer.dart' + name: DateSerializer + - import: 'package:end_to_end_test_tristate/custom_field_serializer.dart' + name: CustomFieldSerializer + type_overrides: + Date: + name: DateTime + CustomField: + name: CustomField + import: 'package:end_to_end_test_tristate/custom_field.dart' + gql_build|schema_builder: + enabled: true + options: + tristate_optionals: true + enum_fallbacks: + LengthUnit: METER + type_overrides: + Date: + name: DateTime + CustomField: + name: CustomField + import: 'package:end_to_end_test_tristate/custom_field.dart' + gql_build|data_builder: + enabled: true + options: + schema: end_to_end_test_tristate|lib/graphql/schema.graphql + when_extensions: + when: true + maybeWhen: true + type_overrides: + Date: + name: DateTime + CustomField: + name: CustomField + import: 'package:end_to_end_test_tristate/custom_field.dart' + gql_build|var_builder: + enabled: true + options: + schema: end_to_end_test_tristate|lib/graphql/schema.graphql + tristate_optionals: true + type_overrides: + Date: + name: DateTime + CustomField: + name: CustomField + import: 'package:end_to_end_test_tristate/custom_field.dart' diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.ast.gql.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.ast.gql.dart new file mode 100644 index 00000000..f559a4f1 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.ast.gql.dart @@ -0,0 +1,113 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const PostFragment = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'PostFragment'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Post'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'favoritedUsers'), + alias: _i1.NameNode(value: 'isFavorited'), + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'where'), + value: _i1.ObjectValueNode(fields: [ + _i1.ObjectFieldNode( + name: _i1.NameNode(value: 'id'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'userId')), + ) + ]), + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'totalCount'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'likedUsers'), + alias: _i1.NameNode(value: 'isLiked'), + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'where'), + value: _i1.ObjectValueNode(fields: [ + _i1.ObjectFieldNode( + name: _i1.NameNode(value: 'id'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'userId')), + ) + ]), + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'totalCount'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), + ), + ]), +); +const Posts = _i1.OperationDefinitionNode( + type: _i1.OperationType.query, + name: _i1.NameNode(value: 'Posts'), + variableDefinitions: [ + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'userId')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'posts'), + alias: null, + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'userId'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'userId')), + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'PostFragment'), + directives: [], + ) + ]), + ) + ]), +); +const document = _i1.DocumentNode(definitions: [ + PostFragment, + Posts, +]); diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.data.gql.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.data.gql.dart new file mode 100644 index 00000000..f497c61b --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.data.gql.dart @@ -0,0 +1,266 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'alias_var_fragment.data.gql.g.dart'; + +abstract class GPostsData implements Built { + GPostsData._(); + + factory GPostsData([Function(GPostsDataBuilder b) updates]) = _$GPostsData; + + static void _initializeBuilder(GPostsDataBuilder b) => + b..G__typename = 'Query'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + BuiltList? get posts; + static Serializer get serializer => _$gPostsDataSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GPostsData.serializer, + this, + ) as Map); + + static GPostsData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GPostsData.serializer, + json, + ); +} + +abstract class GPostsData_posts + implements Built, GPostFragment { + GPostsData_posts._(); + + factory GPostsData_posts([Function(GPostsData_postsBuilder b) updates]) = + _$GPostsData_posts; + + static void _initializeBuilder(GPostsData_postsBuilder b) => + b..G__typename = 'Post'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get id; + @override + GPostsData_posts_isFavorited? get isFavorited; + @override + GPostsData_posts_isLiked? get isLiked; + static Serializer get serializer => + _$gPostsDataPostsSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GPostsData_posts.serializer, + this, + ) as Map); + + static GPostsData_posts? fromJson(Map json) => + _i1.serializers.deserializeWith( + GPostsData_posts.serializer, + json, + ); +} + +abstract class GPostsData_posts_isFavorited + implements + Built, + GPostFragment_isFavorited { + GPostsData_posts_isFavorited._(); + + factory GPostsData_posts_isFavorited( + [Function(GPostsData_posts_isFavoritedBuilder b) updates]) = + _$GPostsData_posts_isFavorited; + + static void _initializeBuilder(GPostsData_posts_isFavoritedBuilder b) => + b..G__typename = 'PostLikes'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + int get totalCount; + static Serializer get serializer => + _$gPostsDataPostsIsFavoritedSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GPostsData_posts_isFavorited.serializer, + this, + ) as Map); + + static GPostsData_posts_isFavorited? fromJson(Map json) => + _i1.serializers.deserializeWith( + GPostsData_posts_isFavorited.serializer, + json, + ); +} + +abstract class GPostsData_posts_isLiked + implements + Built, + GPostFragment_isLiked { + GPostsData_posts_isLiked._(); + + factory GPostsData_posts_isLiked( + [Function(GPostsData_posts_isLikedBuilder b) updates]) = + _$GPostsData_posts_isLiked; + + static void _initializeBuilder(GPostsData_posts_isLikedBuilder b) => + b..G__typename = 'PostFavorites'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + int get totalCount; + static Serializer get serializer => + _$gPostsDataPostsIsLikedSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GPostsData_posts_isLiked.serializer, + this, + ) as Map); + + static GPostsData_posts_isLiked? fromJson(Map json) => + _i1.serializers.deserializeWith( + GPostsData_posts_isLiked.serializer, + json, + ); +} + +abstract class GPostFragment { + String get G__typename; + String get id; + GPostFragment_isFavorited? get isFavorited; + GPostFragment_isLiked? get isLiked; + Map toJson(); +} + +abstract class GPostFragment_isFavorited { + String get G__typename; + int get totalCount; + Map toJson(); +} + +abstract class GPostFragment_isLiked { + String get G__typename; + int get totalCount; + Map toJson(); +} + +abstract class GPostFragmentData + implements + Built, + GPostFragment { + GPostFragmentData._(); + + factory GPostFragmentData([Function(GPostFragmentDataBuilder b) updates]) = + _$GPostFragmentData; + + static void _initializeBuilder(GPostFragmentDataBuilder b) => + b..G__typename = 'Post'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get id; + @override + GPostFragmentData_isFavorited? get isFavorited; + @override + GPostFragmentData_isLiked? get isLiked; + static Serializer get serializer => + _$gPostFragmentDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GPostFragmentData.serializer, + this, + ) as Map); + + static GPostFragmentData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GPostFragmentData.serializer, + json, + ); +} + +abstract class GPostFragmentData_isFavorited + implements + Built, + GPostFragment_isFavorited { + GPostFragmentData_isFavorited._(); + + factory GPostFragmentData_isFavorited( + [Function(GPostFragmentData_isFavoritedBuilder b) updates]) = + _$GPostFragmentData_isFavorited; + + static void _initializeBuilder(GPostFragmentData_isFavoritedBuilder b) => + b..G__typename = 'PostLikes'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + int get totalCount; + static Serializer get serializer => + _$gPostFragmentDataIsFavoritedSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GPostFragmentData_isFavorited.serializer, + this, + ) as Map); + + static GPostFragmentData_isFavorited? fromJson(Map json) => + _i1.serializers.deserializeWith( + GPostFragmentData_isFavorited.serializer, + json, + ); +} + +abstract class GPostFragmentData_isLiked + implements + Built, + GPostFragment_isLiked { + GPostFragmentData_isLiked._(); + + factory GPostFragmentData_isLiked( + [Function(GPostFragmentData_isLikedBuilder b) updates]) = + _$GPostFragmentData_isLiked; + + static void _initializeBuilder(GPostFragmentData_isLikedBuilder b) => + b..G__typename = 'PostFavorites'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + int get totalCount; + static Serializer get serializer => + _$gPostFragmentDataIsLikedSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GPostFragmentData_isLiked.serializer, + this, + ) as Map); + + static GPostFragmentData_isLiked? fromJson(Map json) => + _i1.serializers.deserializeWith( + GPostFragmentData_isLiked.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.data.gql.g.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.data.gql.g.dart new file mode 100644 index 00000000..bdd60526 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.data.gql.g.dart @@ -0,0 +1,1272 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'alias_var_fragment.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gPostsDataSerializer = new _$GPostsDataSerializer(); +Serializer _$gPostsDataPostsSerializer = + new _$GPostsData_postsSerializer(); +Serializer + _$gPostsDataPostsIsFavoritedSerializer = + new _$GPostsData_posts_isFavoritedSerializer(); +Serializer _$gPostsDataPostsIsLikedSerializer = + new _$GPostsData_posts_isLikedSerializer(); +Serializer _$gPostFragmentDataSerializer = + new _$GPostFragmentDataSerializer(); +Serializer + _$gPostFragmentDataIsFavoritedSerializer = + new _$GPostFragmentData_isFavoritedSerializer(); +Serializer _$gPostFragmentDataIsLikedSerializer = + new _$GPostFragmentData_isLikedSerializer(); + +class _$GPostsDataSerializer implements StructuredSerializer { + @override + final Iterable types = const [GPostsData, _$GPostsData]; + @override + final String wireName = 'GPostsData'; + + @override + Iterable serialize(Serializers serializers, GPostsData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.posts; + if (value != null) { + result + ..add('posts') + ..add(serializers.serialize(value, + specifiedType: const FullType( + BuiltList, const [const FullType.nullable(GPostsData_posts)]))); + } + return result; + } + + @override + GPostsData deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostsDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'posts': + result.posts.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable(GPostsData_posts) + ]))! as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$GPostsData_postsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GPostsData_posts, _$GPostsData_posts]; + @override + final String wireName = 'GPostsData_posts'; + + @override + Iterable serialize(Serializers serializers, GPostsData_posts object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.isFavorited; + if (value != null) { + result + ..add('isFavorited') + ..add(serializers.serialize(value, + specifiedType: const FullType(GPostsData_posts_isFavorited))); + } + value = object.isLiked; + if (value != null) { + result + ..add('isLiked') + ..add(serializers.serialize(value, + specifiedType: const FullType(GPostsData_posts_isLiked))); + } + return result; + } + + @override + GPostsData_posts deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostsData_postsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'isFavorited': + result.isFavorited.replace(serializers.deserialize(value, + specifiedType: const FullType(GPostsData_posts_isFavorited))! + as GPostsData_posts_isFavorited); + break; + case 'isLiked': + result.isLiked.replace(serializers.deserialize(value, + specifiedType: const FullType(GPostsData_posts_isLiked))! + as GPostsData_posts_isLiked); + break; + } + } + + return result.build(); + } +} + +class _$GPostsData_posts_isFavoritedSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GPostsData_posts_isFavorited, + _$GPostsData_posts_isFavorited + ]; + @override + final String wireName = 'GPostsData_posts_isFavorited'; + + @override + Iterable serialize( + Serializers serializers, GPostsData_posts_isFavorited object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'totalCount', + serializers.serialize(object.totalCount, + specifiedType: const FullType(int)), + ]; + + return result; + } + + @override + GPostsData_posts_isFavorited deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostsData_posts_isFavoritedBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'totalCount': + result.totalCount = serializers.deserialize(value, + specifiedType: const FullType(int))! as int; + break; + } + } + + return result.build(); + } +} + +class _$GPostsData_posts_isLikedSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GPostsData_posts_isLiked, + _$GPostsData_posts_isLiked + ]; + @override + final String wireName = 'GPostsData_posts_isLiked'; + + @override + Iterable serialize( + Serializers serializers, GPostsData_posts_isLiked object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'totalCount', + serializers.serialize(object.totalCount, + specifiedType: const FullType(int)), + ]; + + return result; + } + + @override + GPostsData_posts_isLiked deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostsData_posts_isLikedBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'totalCount': + result.totalCount = serializers.deserialize(value, + specifiedType: const FullType(int))! as int; + break; + } + } + + return result.build(); + } +} + +class _$GPostFragmentDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GPostFragmentData, _$GPostFragmentData]; + @override + final String wireName = 'GPostFragmentData'; + + @override + Iterable serialize(Serializers serializers, GPostFragmentData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.isFavorited; + if (value != null) { + result + ..add('isFavorited') + ..add(serializers.serialize(value, + specifiedType: const FullType(GPostFragmentData_isFavorited))); + } + value = object.isLiked; + if (value != null) { + result + ..add('isLiked') + ..add(serializers.serialize(value, + specifiedType: const FullType(GPostFragmentData_isLiked))); + } + return result; + } + + @override + GPostFragmentData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostFragmentDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'isFavorited': + result.isFavorited.replace(serializers.deserialize(value, + specifiedType: const FullType(GPostFragmentData_isFavorited))! + as GPostFragmentData_isFavorited); + break; + case 'isLiked': + result.isLiked.replace(serializers.deserialize(value, + specifiedType: const FullType(GPostFragmentData_isLiked))! + as GPostFragmentData_isLiked); + break; + } + } + + return result.build(); + } +} + +class _$GPostFragmentData_isFavoritedSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GPostFragmentData_isFavorited, + _$GPostFragmentData_isFavorited + ]; + @override + final String wireName = 'GPostFragmentData_isFavorited'; + + @override + Iterable serialize( + Serializers serializers, GPostFragmentData_isFavorited object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'totalCount', + serializers.serialize(object.totalCount, + specifiedType: const FullType(int)), + ]; + + return result; + } + + @override + GPostFragmentData_isFavorited deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostFragmentData_isFavoritedBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'totalCount': + result.totalCount = serializers.deserialize(value, + specifiedType: const FullType(int))! as int; + break; + } + } + + return result.build(); + } +} + +class _$GPostFragmentData_isLikedSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GPostFragmentData_isLiked, + _$GPostFragmentData_isLiked + ]; + @override + final String wireName = 'GPostFragmentData_isLiked'; + + @override + Iterable serialize( + Serializers serializers, GPostFragmentData_isLiked object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'totalCount', + serializers.serialize(object.totalCount, + specifiedType: const FullType(int)), + ]; + + return result; + } + + @override + GPostFragmentData_isLiked deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostFragmentData_isLikedBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'totalCount': + result.totalCount = serializers.deserialize(value, + specifiedType: const FullType(int))! as int; + break; + } + } + + return result.build(); + } +} + +class _$GPostsData extends GPostsData { + @override + final String G__typename; + @override + final BuiltList? posts; + + factory _$GPostsData([void Function(GPostsDataBuilder)? updates]) => + (new GPostsDataBuilder()..update(updates))._build(); + + _$GPostsData._({required this.G__typename, this.posts}) : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostsData', 'G__typename'); + } + + @override + GPostsData rebuild(void Function(GPostsDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostsDataBuilder toBuilder() => new GPostsDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostsData && + G__typename == other.G__typename && + posts == other.posts; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, posts.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostsData') + ..add('G__typename', G__typename) + ..add('posts', posts)) + .toString(); + } +} + +class GPostsDataBuilder implements Builder { + _$GPostsData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + ListBuilder? _posts; + ListBuilder get posts => + _$this._posts ??= new ListBuilder(); + set posts(ListBuilder? posts) => _$this._posts = posts; + + GPostsDataBuilder() { + GPostsData._initializeBuilder(this); + } + + GPostsDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _posts = $v.posts?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GPostsData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostsData; + } + + @override + void update(void Function(GPostsDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostsData build() => _build(); + + _$GPostsData _build() { + _$GPostsData _$result; + try { + _$result = _$v ?? + new _$GPostsData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostsData', 'G__typename'), + posts: _posts?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'posts'; + _posts?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GPostsData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GPostsData_posts extends GPostsData_posts { + @override + final String G__typename; + @override + final String id; + @override + final GPostsData_posts_isFavorited? isFavorited; + @override + final GPostsData_posts_isLiked? isLiked; + + factory _$GPostsData_posts( + [void Function(GPostsData_postsBuilder)? updates]) => + (new GPostsData_postsBuilder()..update(updates))._build(); + + _$GPostsData_posts._( + {required this.G__typename, + required this.id, + this.isFavorited, + this.isLiked}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostsData_posts', 'G__typename'); + BuiltValueNullFieldError.checkNotNull(id, r'GPostsData_posts', 'id'); + } + + @override + GPostsData_posts rebuild(void Function(GPostsData_postsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostsData_postsBuilder toBuilder() => + new GPostsData_postsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostsData_posts && + G__typename == other.G__typename && + id == other.id && + isFavorited == other.isFavorited && + isLiked == other.isLiked; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, isFavorited.hashCode); + _$hash = $jc(_$hash, isLiked.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostsData_posts') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('isFavorited', isFavorited) + ..add('isLiked', isLiked)) + .toString(); + } +} + +class GPostsData_postsBuilder + implements Builder { + _$GPostsData_posts? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + GPostsData_posts_isFavoritedBuilder? _isFavorited; + GPostsData_posts_isFavoritedBuilder get isFavorited => + _$this._isFavorited ??= new GPostsData_posts_isFavoritedBuilder(); + set isFavorited(GPostsData_posts_isFavoritedBuilder? isFavorited) => + _$this._isFavorited = isFavorited; + + GPostsData_posts_isLikedBuilder? _isLiked; + GPostsData_posts_isLikedBuilder get isLiked => + _$this._isLiked ??= new GPostsData_posts_isLikedBuilder(); + set isLiked(GPostsData_posts_isLikedBuilder? isLiked) => + _$this._isLiked = isLiked; + + GPostsData_postsBuilder() { + GPostsData_posts._initializeBuilder(this); + } + + GPostsData_postsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _isFavorited = $v.isFavorited?.toBuilder(); + _isLiked = $v.isLiked?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GPostsData_posts other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostsData_posts; + } + + @override + void update(void Function(GPostsData_postsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostsData_posts build() => _build(); + + _$GPostsData_posts _build() { + _$GPostsData_posts _$result; + try { + _$result = _$v ?? + new _$GPostsData_posts._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostsData_posts', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GPostsData_posts', 'id'), + isFavorited: _isFavorited?.build(), + isLiked: _isLiked?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'isFavorited'; + _isFavorited?.build(); + _$failedField = 'isLiked'; + _isLiked?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GPostsData_posts', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GPostsData_posts_isFavorited extends GPostsData_posts_isFavorited { + @override + final String G__typename; + @override + final int totalCount; + + factory _$GPostsData_posts_isFavorited( + [void Function(GPostsData_posts_isFavoritedBuilder)? updates]) => + (new GPostsData_posts_isFavoritedBuilder()..update(updates))._build(); + + _$GPostsData_posts_isFavorited._( + {required this.G__typename, required this.totalCount}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostsData_posts_isFavorited', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + totalCount, r'GPostsData_posts_isFavorited', 'totalCount'); + } + + @override + GPostsData_posts_isFavorited rebuild( + void Function(GPostsData_posts_isFavoritedBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostsData_posts_isFavoritedBuilder toBuilder() => + new GPostsData_posts_isFavoritedBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostsData_posts_isFavorited && + G__typename == other.G__typename && + totalCount == other.totalCount; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, totalCount.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostsData_posts_isFavorited') + ..add('G__typename', G__typename) + ..add('totalCount', totalCount)) + .toString(); + } +} + +class GPostsData_posts_isFavoritedBuilder + implements + Builder { + _$GPostsData_posts_isFavorited? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + int? _totalCount; + int? get totalCount => _$this._totalCount; + set totalCount(int? totalCount) => _$this._totalCount = totalCount; + + GPostsData_posts_isFavoritedBuilder() { + GPostsData_posts_isFavorited._initializeBuilder(this); + } + + GPostsData_posts_isFavoritedBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _totalCount = $v.totalCount; + _$v = null; + } + return this; + } + + @override + void replace(GPostsData_posts_isFavorited other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostsData_posts_isFavorited; + } + + @override + void update(void Function(GPostsData_posts_isFavoritedBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostsData_posts_isFavorited build() => _build(); + + _$GPostsData_posts_isFavorited _build() { + final _$result = _$v ?? + new _$GPostsData_posts_isFavorited._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostsData_posts_isFavorited', 'G__typename'), + totalCount: BuiltValueNullFieldError.checkNotNull( + totalCount, r'GPostsData_posts_isFavorited', 'totalCount')); + replace(_$result); + return _$result; + } +} + +class _$GPostsData_posts_isLiked extends GPostsData_posts_isLiked { + @override + final String G__typename; + @override + final int totalCount; + + factory _$GPostsData_posts_isLiked( + [void Function(GPostsData_posts_isLikedBuilder)? updates]) => + (new GPostsData_posts_isLikedBuilder()..update(updates))._build(); + + _$GPostsData_posts_isLiked._( + {required this.G__typename, required this.totalCount}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostsData_posts_isLiked', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + totalCount, r'GPostsData_posts_isLiked', 'totalCount'); + } + + @override + GPostsData_posts_isLiked rebuild( + void Function(GPostsData_posts_isLikedBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostsData_posts_isLikedBuilder toBuilder() => + new GPostsData_posts_isLikedBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostsData_posts_isLiked && + G__typename == other.G__typename && + totalCount == other.totalCount; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, totalCount.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostsData_posts_isLiked') + ..add('G__typename', G__typename) + ..add('totalCount', totalCount)) + .toString(); + } +} + +class GPostsData_posts_isLikedBuilder + implements + Builder { + _$GPostsData_posts_isLiked? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + int? _totalCount; + int? get totalCount => _$this._totalCount; + set totalCount(int? totalCount) => _$this._totalCount = totalCount; + + GPostsData_posts_isLikedBuilder() { + GPostsData_posts_isLiked._initializeBuilder(this); + } + + GPostsData_posts_isLikedBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _totalCount = $v.totalCount; + _$v = null; + } + return this; + } + + @override + void replace(GPostsData_posts_isLiked other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostsData_posts_isLiked; + } + + @override + void update(void Function(GPostsData_posts_isLikedBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostsData_posts_isLiked build() => _build(); + + _$GPostsData_posts_isLiked _build() { + final _$result = _$v ?? + new _$GPostsData_posts_isLiked._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostsData_posts_isLiked', 'G__typename'), + totalCount: BuiltValueNullFieldError.checkNotNull( + totalCount, r'GPostsData_posts_isLiked', 'totalCount')); + replace(_$result); + return _$result; + } +} + +class _$GPostFragmentData extends GPostFragmentData { + @override + final String G__typename; + @override + final String id; + @override + final GPostFragmentData_isFavorited? isFavorited; + @override + final GPostFragmentData_isLiked? isLiked; + + factory _$GPostFragmentData( + [void Function(GPostFragmentDataBuilder)? updates]) => + (new GPostFragmentDataBuilder()..update(updates))._build(); + + _$GPostFragmentData._( + {required this.G__typename, + required this.id, + this.isFavorited, + this.isLiked}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostFragmentData', 'G__typename'); + BuiltValueNullFieldError.checkNotNull(id, r'GPostFragmentData', 'id'); + } + + @override + GPostFragmentData rebuild(void Function(GPostFragmentDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostFragmentDataBuilder toBuilder() => + new GPostFragmentDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostFragmentData && + G__typename == other.G__typename && + id == other.id && + isFavorited == other.isFavorited && + isLiked == other.isLiked; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, isFavorited.hashCode); + _$hash = $jc(_$hash, isLiked.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostFragmentData') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('isFavorited', isFavorited) + ..add('isLiked', isLiked)) + .toString(); + } +} + +class GPostFragmentDataBuilder + implements Builder { + _$GPostFragmentData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + GPostFragmentData_isFavoritedBuilder? _isFavorited; + GPostFragmentData_isFavoritedBuilder get isFavorited => + _$this._isFavorited ??= new GPostFragmentData_isFavoritedBuilder(); + set isFavorited(GPostFragmentData_isFavoritedBuilder? isFavorited) => + _$this._isFavorited = isFavorited; + + GPostFragmentData_isLikedBuilder? _isLiked; + GPostFragmentData_isLikedBuilder get isLiked => + _$this._isLiked ??= new GPostFragmentData_isLikedBuilder(); + set isLiked(GPostFragmentData_isLikedBuilder? isLiked) => + _$this._isLiked = isLiked; + + GPostFragmentDataBuilder() { + GPostFragmentData._initializeBuilder(this); + } + + GPostFragmentDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _isFavorited = $v.isFavorited?.toBuilder(); + _isLiked = $v.isLiked?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GPostFragmentData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostFragmentData; + } + + @override + void update(void Function(GPostFragmentDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostFragmentData build() => _build(); + + _$GPostFragmentData _build() { + _$GPostFragmentData _$result; + try { + _$result = _$v ?? + new _$GPostFragmentData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostFragmentData', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GPostFragmentData', 'id'), + isFavorited: _isFavorited?.build(), + isLiked: _isLiked?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'isFavorited'; + _isFavorited?.build(); + _$failedField = 'isLiked'; + _isLiked?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GPostFragmentData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GPostFragmentData_isFavorited extends GPostFragmentData_isFavorited { + @override + final String G__typename; + @override + final int totalCount; + + factory _$GPostFragmentData_isFavorited( + [void Function(GPostFragmentData_isFavoritedBuilder)? updates]) => + (new GPostFragmentData_isFavoritedBuilder()..update(updates))._build(); + + _$GPostFragmentData_isFavorited._( + {required this.G__typename, required this.totalCount}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostFragmentData_isFavorited', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + totalCount, r'GPostFragmentData_isFavorited', 'totalCount'); + } + + @override + GPostFragmentData_isFavorited rebuild( + void Function(GPostFragmentData_isFavoritedBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostFragmentData_isFavoritedBuilder toBuilder() => + new GPostFragmentData_isFavoritedBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostFragmentData_isFavorited && + G__typename == other.G__typename && + totalCount == other.totalCount; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, totalCount.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostFragmentData_isFavorited') + ..add('G__typename', G__typename) + ..add('totalCount', totalCount)) + .toString(); + } +} + +class GPostFragmentData_isFavoritedBuilder + implements + Builder { + _$GPostFragmentData_isFavorited? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + int? _totalCount; + int? get totalCount => _$this._totalCount; + set totalCount(int? totalCount) => _$this._totalCount = totalCount; + + GPostFragmentData_isFavoritedBuilder() { + GPostFragmentData_isFavorited._initializeBuilder(this); + } + + GPostFragmentData_isFavoritedBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _totalCount = $v.totalCount; + _$v = null; + } + return this; + } + + @override + void replace(GPostFragmentData_isFavorited other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostFragmentData_isFavorited; + } + + @override + void update(void Function(GPostFragmentData_isFavoritedBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostFragmentData_isFavorited build() => _build(); + + _$GPostFragmentData_isFavorited _build() { + final _$result = _$v ?? + new _$GPostFragmentData_isFavorited._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostFragmentData_isFavorited', 'G__typename'), + totalCount: BuiltValueNullFieldError.checkNotNull( + totalCount, r'GPostFragmentData_isFavorited', 'totalCount')); + replace(_$result); + return _$result; + } +} + +class _$GPostFragmentData_isLiked extends GPostFragmentData_isLiked { + @override + final String G__typename; + @override + final int totalCount; + + factory _$GPostFragmentData_isLiked( + [void Function(GPostFragmentData_isLikedBuilder)? updates]) => + (new GPostFragmentData_isLikedBuilder()..update(updates))._build(); + + _$GPostFragmentData_isLiked._( + {required this.G__typename, required this.totalCount}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostFragmentData_isLiked', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + totalCount, r'GPostFragmentData_isLiked', 'totalCount'); + } + + @override + GPostFragmentData_isLiked rebuild( + void Function(GPostFragmentData_isLikedBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostFragmentData_isLikedBuilder toBuilder() => + new GPostFragmentData_isLikedBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostFragmentData_isLiked && + G__typename == other.G__typename && + totalCount == other.totalCount; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, totalCount.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostFragmentData_isLiked') + ..add('G__typename', G__typename) + ..add('totalCount', totalCount)) + .toString(); + } +} + +class GPostFragmentData_isLikedBuilder + implements + Builder { + _$GPostFragmentData_isLiked? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + int? _totalCount; + int? get totalCount => _$this._totalCount; + set totalCount(int? totalCount) => _$this._totalCount = totalCount; + + GPostFragmentData_isLikedBuilder() { + GPostFragmentData_isLiked._initializeBuilder(this); + } + + GPostFragmentData_isLikedBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _totalCount = $v.totalCount; + _$v = null; + } + return this; + } + + @override + void replace(GPostFragmentData_isLiked other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostFragmentData_isLiked; + } + + @override + void update(void Function(GPostFragmentData_isLikedBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostFragmentData_isLiked build() => _build(); + + _$GPostFragmentData_isLiked _build() { + final _$result = _$v ?? + new _$GPostFragmentData_isLiked._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostFragmentData_isLiked', 'G__typename'), + totalCount: BuiltValueNullFieldError.checkNotNull( + totalCount, r'GPostFragmentData_isLiked', 'totalCount')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.req.gql.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.req.gql.dart new file mode 100644 index 00000000..68f84cee --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.req.gql.dart @@ -0,0 +1,42 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/aliases/__generated__/alias_var_fragment.ast.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/aliases/__generated__/alias_var_fragment.var.gql.dart' + as _i3; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'alias_var_fragment.req.gql.g.dart'; + +abstract class GPosts implements Built { + GPosts._(); + + factory GPosts([Function(GPostsBuilder b) updates]) = _$GPosts; + + static void _initializeBuilder(GPostsBuilder b) => b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'Posts', + ); + + _i3.GPostsVars get vars; + _i1.Operation get operation; + static Serializer get serializer => _$gPostsSerializer; + + Map toJson() => (_i4.serializers.serializeWith( + GPosts.serializer, + this, + ) as Map); + + static GPosts? fromJson(Map json) => + _i4.serializers.deserializeWith( + GPosts.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.req.gql.g.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.req.gql.g.dart new file mode 100644 index 00000000..0f8996ec --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.req.gql.g.dart @@ -0,0 +1,170 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'alias_var_fragment.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gPostsSerializer = new _$GPostsSerializer(); + +class _$GPostsSerializer implements StructuredSerializer { + @override + final Iterable types = const [GPosts, _$GPosts]; + @override + final String wireName = 'GPosts'; + + @override + Iterable serialize(Serializers serializers, GPosts object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: const FullType(_i3.GPostsVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GPosts deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'vars': + result.vars.replace(serializers.deserialize(value, + specifiedType: const FullType(_i3.GPostsVars))! + as _i3.GPostsVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GPosts extends GPosts { + @override + final _i3.GPostsVars vars; + @override + final _i1.Operation operation; + + factory _$GPosts([void Function(GPostsBuilder)? updates]) => + (new GPostsBuilder()..update(updates))._build(); + + _$GPosts._({required this.vars, required this.operation}) : super._() { + BuiltValueNullFieldError.checkNotNull(vars, r'GPosts', 'vars'); + BuiltValueNullFieldError.checkNotNull(operation, r'GPosts', 'operation'); + } + + @override + GPosts rebuild(void Function(GPostsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostsBuilder toBuilder() => new GPostsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPosts && + vars == other.vars && + operation == other.operation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPosts') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GPostsBuilder implements Builder { + _$GPosts? _$v; + + _i3.GPostsVarsBuilder? _vars; + _i3.GPostsVarsBuilder get vars => + _$this._vars ??= new _i3.GPostsVarsBuilder(); + set vars(_i3.GPostsVarsBuilder? vars) => _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GPostsBuilder() { + GPosts._initializeBuilder(this); + } + + GPostsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GPosts other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPosts; + } + + @override + void update(void Function(GPostsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPosts build() => _build(); + + _$GPosts _build() { + _$GPosts _$result; + try { + _$result = _$v ?? + new _$GPosts._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull( + operation, r'GPosts', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GPosts', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.dart new file mode 100644 index 00000000..bdad206b --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.dart @@ -0,0 +1,136 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'alias_var_fragment.var.gql.g.dart'; + +abstract class GPostsVars implements Built { + GPostsVars._(); + + factory GPostsVars([Function(GPostsVarsBuilder b) updates]) = _$GPostsVars; + + String get userId; + Map toJson() => (_i1.serializers.serializeWith( + GPostsVars.serializer, + this, + ) as Map); + + static GPostsVars? fromJson(Map json) => + _i1.serializers.deserializeWith( + GPostsVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => GPostsVarsSerializer(); +} + +abstract class GPostFragmentVars + implements Built { + GPostFragmentVars._(); + + factory GPostFragmentVars([Function(GPostFragmentVarsBuilder b) updates]) = + _$GPostFragmentVars; + + String get userId; + Map toJson() => (_i1.serializers.serializeWith( + GPostFragmentVars.serializer, + this, + ) as Map); + + static GPostFragmentVars? fromJson(Map json) => + _i1.serializers.deserializeWith( + GPostFragmentVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GPostFragmentVarsSerializer(); +} + +class GPostsVarsSerializer extends StructuredSerializer { + final String wireName = 'GPostsVars'; + + final Iterable types = const [GPostsVars, _$GPostsVars]; + + Iterable serialize( + Serializers serializers, + GPostsVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('userId'); + result.add(serializers.serialize(object.userId, + specifiedType: const FullType(String))); + return result; + } + + GPostsVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GPostsVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'userId': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + builder.userId = fieldValue; + break; + } + } + return builder.build(); + } +} + +class GPostFragmentVarsSerializer + extends StructuredSerializer { + final String wireName = 'GPostFragmentVars'; + + final Iterable types = const [GPostFragmentVars, _$GPostFragmentVars]; + + Iterable serialize( + Serializers serializers, + GPostFragmentVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('userId'); + result.add(serializers.serialize(object.userId, + specifiedType: const FullType(String))); + return result; + } + + GPostFragmentVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GPostFragmentVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'userId': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + builder.userId = fieldValue; + break; + } + } + return builder.build(); + } +} diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.g.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.g.dart new file mode 100644 index 00000000..fdce65cf --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.g.dart @@ -0,0 +1,176 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'alias_var_fragment.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$GPostsVars extends GPostsVars { + @override + final String userId; + + factory _$GPostsVars([void Function(GPostsVarsBuilder)? updates]) => + (new GPostsVarsBuilder()..update(updates))._build(); + + _$GPostsVars._({required this.userId}) : super._() { + BuiltValueNullFieldError.checkNotNull(userId, r'GPostsVars', 'userId'); + } + + @override + GPostsVars rebuild(void Function(GPostsVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostsVarsBuilder toBuilder() => new GPostsVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostsVars && userId == other.userId; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, userId.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostsVars')..add('userId', userId)) + .toString(); + } +} + +class GPostsVarsBuilder implements Builder { + _$GPostsVars? _$v; + + String? _userId; + String? get userId => _$this._userId; + set userId(String? userId) => _$this._userId = userId; + + GPostsVarsBuilder(); + + GPostsVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _userId = $v.userId; + _$v = null; + } + return this; + } + + @override + void replace(GPostsVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostsVars; + } + + @override + void update(void Function(GPostsVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostsVars build() => _build(); + + _$GPostsVars _build() { + final _$result = _$v ?? + new _$GPostsVars._( + userId: BuiltValueNullFieldError.checkNotNull( + userId, r'GPostsVars', 'userId')); + replace(_$result); + return _$result; + } +} + +class _$GPostFragmentVars extends GPostFragmentVars { + @override + final String userId; + + factory _$GPostFragmentVars( + [void Function(GPostFragmentVarsBuilder)? updates]) => + (new GPostFragmentVarsBuilder()..update(updates))._build(); + + _$GPostFragmentVars._({required this.userId}) : super._() { + BuiltValueNullFieldError.checkNotNull( + userId, r'GPostFragmentVars', 'userId'); + } + + @override + GPostFragmentVars rebuild(void Function(GPostFragmentVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostFragmentVarsBuilder toBuilder() => + new GPostFragmentVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostFragmentVars && userId == other.userId; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, userId.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostFragmentVars') + ..add('userId', userId)) + .toString(); + } +} + +class GPostFragmentVarsBuilder + implements Builder { + _$GPostFragmentVars? _$v; + + String? _userId; + String? get userId => _$this._userId; + set userId(String? userId) => _$this._userId = userId; + + GPostFragmentVarsBuilder(); + + GPostFragmentVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _userId = $v.userId; + _$v = null; + } + return this; + } + + @override + void replace(GPostFragmentVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostFragmentVars; + } + + @override + void update(void Function(GPostFragmentVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostFragmentVars build() => _build(); + + _$GPostFragmentVars _build() { + final _$result = _$v ?? + new _$GPostFragmentVars._( + userId: BuiltValueNullFieldError.checkNotNull( + userId, r'GPostFragmentVars', 'userId')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.ast.gql.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.ast.gql.dart new file mode 100644 index 00000000..95bb5767 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.ast.gql.dart @@ -0,0 +1,93 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const AliasedHero = _i1.OperationDefinitionNode( + type: _i1.OperationType.query, + name: _i1.NameNode(value: 'AliasedHero'), + variableDefinitions: [ + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'ep')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Episode'), + isNonNull: true, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'hero'), + alias: _i1.NameNode(value: 'empireHero'), + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'episode'), + value: _i1.EnumValueNode(name: _i1.NameNode(value: 'EMPIRE')), + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'appearsIn'), + alias: _i1.NameNode(value: 'from'), + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'hero'), + alias: _i1.NameNode(value: 'jediHero'), + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'episode'), + value: _i1.EnumValueNode(name: _i1.NameNode(value: 'JEDI')), + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'appearsIn'), + alias: _i1.NameNode(value: 'from'), + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + ]), +); +const document = _i1.DocumentNode(definitions: [AliasedHero]); diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.data.gql.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.data.gql.dart new file mode 100644 index 00000000..344a78d6 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.data.gql.dart @@ -0,0 +1,106 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'aliased_hero.data.gql.g.dart'; + +abstract class GAliasedHeroData + implements Built { + GAliasedHeroData._(); + + factory GAliasedHeroData([Function(GAliasedHeroDataBuilder b) updates]) = + _$GAliasedHeroData; + + static void _initializeBuilder(GAliasedHeroDataBuilder b) => + b..G__typename = 'Query'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + GAliasedHeroData_empireHero? get empireHero; + GAliasedHeroData_jediHero? get jediHero; + static Serializer get serializer => + _$gAliasedHeroDataSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GAliasedHeroData.serializer, + this, + ) as Map); + + static GAliasedHeroData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GAliasedHeroData.serializer, + json, + ); +} + +abstract class GAliasedHeroData_empireHero + implements + Built { + GAliasedHeroData_empireHero._(); + + factory GAliasedHeroData_empireHero( + [Function(GAliasedHeroData_empireHeroBuilder b) updates]) = + _$GAliasedHeroData_empireHero; + + static void _initializeBuilder(GAliasedHeroData_empireHeroBuilder b) => + b..G__typename = 'Character'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + String get id; + String get name; + BuiltList<_i2.GEpisode?> get from; + static Serializer get serializer => + _$gAliasedHeroDataEmpireHeroSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GAliasedHeroData_empireHero.serializer, + this, + ) as Map); + + static GAliasedHeroData_empireHero? fromJson(Map json) => + _i1.serializers.deserializeWith( + GAliasedHeroData_empireHero.serializer, + json, + ); +} + +abstract class GAliasedHeroData_jediHero + implements + Built { + GAliasedHeroData_jediHero._(); + + factory GAliasedHeroData_jediHero( + [Function(GAliasedHeroData_jediHeroBuilder b) updates]) = + _$GAliasedHeroData_jediHero; + + static void _initializeBuilder(GAliasedHeroData_jediHeroBuilder b) => + b..G__typename = 'Character'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + String get id; + String get name; + BuiltList<_i2.GEpisode?> get from; + static Serializer get serializer => + _$gAliasedHeroDataJediHeroSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GAliasedHeroData_jediHero.serializer, + this, + ) as Map); + + static GAliasedHeroData_jediHero? fromJson(Map json) => + _i1.serializers.deserializeWith( + GAliasedHeroData_jediHero.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.data.gql.g.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.data.gql.g.dart new file mode 100644 index 00000000..6d82d8a2 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.data.gql.g.dart @@ -0,0 +1,653 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'aliased_hero.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gAliasedHeroDataSerializer = + new _$GAliasedHeroDataSerializer(); +Serializer _$gAliasedHeroDataEmpireHeroSerializer = + new _$GAliasedHeroData_empireHeroSerializer(); +Serializer _$gAliasedHeroDataJediHeroSerializer = + new _$GAliasedHeroData_jediHeroSerializer(); + +class _$GAliasedHeroDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GAliasedHeroData, _$GAliasedHeroData]; + @override + final String wireName = 'GAliasedHeroData'; + + @override + Iterable serialize(Serializers serializers, GAliasedHeroData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.empireHero; + if (value != null) { + result + ..add('empireHero') + ..add(serializers.serialize(value, + specifiedType: const FullType(GAliasedHeroData_empireHero))); + } + value = object.jediHero; + if (value != null) { + result + ..add('jediHero') + ..add(serializers.serialize(value, + specifiedType: const FullType(GAliasedHeroData_jediHero))); + } + return result; + } + + @override + GAliasedHeroData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GAliasedHeroDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'empireHero': + result.empireHero.replace(serializers.deserialize(value, + specifiedType: const FullType(GAliasedHeroData_empireHero))! + as GAliasedHeroData_empireHero); + break; + case 'jediHero': + result.jediHero.replace(serializers.deserialize(value, + specifiedType: const FullType(GAliasedHeroData_jediHero))! + as GAliasedHeroData_jediHero); + break; + } + } + + return result.build(); + } +} + +class _$GAliasedHeroData_empireHeroSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GAliasedHeroData_empireHero, + _$GAliasedHeroData_empireHero + ]; + @override + final String wireName = 'GAliasedHeroData_empireHero'; + + @override + Iterable serialize( + Serializers serializers, GAliasedHeroData_empireHero object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + 'from', + serializers.serialize(object.from, + specifiedType: const FullType( + BuiltList, const [const FullType.nullable(_i2.GEpisode)])), + ]; + + return result; + } + + @override + GAliasedHeroData_empireHero deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GAliasedHeroData_empireHeroBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'from': + result.from.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable(_i2.GEpisode) + ]))! as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$GAliasedHeroData_jediHeroSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GAliasedHeroData_jediHero, + _$GAliasedHeroData_jediHero + ]; + @override + final String wireName = 'GAliasedHeroData_jediHero'; + + @override + Iterable serialize( + Serializers serializers, GAliasedHeroData_jediHero object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + 'from', + serializers.serialize(object.from, + specifiedType: const FullType( + BuiltList, const [const FullType.nullable(_i2.GEpisode)])), + ]; + + return result; + } + + @override + GAliasedHeroData_jediHero deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GAliasedHeroData_jediHeroBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'from': + result.from.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable(_i2.GEpisode) + ]))! as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$GAliasedHeroData extends GAliasedHeroData { + @override + final String G__typename; + @override + final GAliasedHeroData_empireHero? empireHero; + @override + final GAliasedHeroData_jediHero? jediHero; + + factory _$GAliasedHeroData( + [void Function(GAliasedHeroDataBuilder)? updates]) => + (new GAliasedHeroDataBuilder()..update(updates))._build(); + + _$GAliasedHeroData._( + {required this.G__typename, this.empireHero, this.jediHero}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GAliasedHeroData', 'G__typename'); + } + + @override + GAliasedHeroData rebuild(void Function(GAliasedHeroDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GAliasedHeroDataBuilder toBuilder() => + new GAliasedHeroDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GAliasedHeroData && + G__typename == other.G__typename && + empireHero == other.empireHero && + jediHero == other.jediHero; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, empireHero.hashCode); + _$hash = $jc(_$hash, jediHero.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GAliasedHeroData') + ..add('G__typename', G__typename) + ..add('empireHero', empireHero) + ..add('jediHero', jediHero)) + .toString(); + } +} + +class GAliasedHeroDataBuilder + implements Builder { + _$GAliasedHeroData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GAliasedHeroData_empireHeroBuilder? _empireHero; + GAliasedHeroData_empireHeroBuilder get empireHero => + _$this._empireHero ??= new GAliasedHeroData_empireHeroBuilder(); + set empireHero(GAliasedHeroData_empireHeroBuilder? empireHero) => + _$this._empireHero = empireHero; + + GAliasedHeroData_jediHeroBuilder? _jediHero; + GAliasedHeroData_jediHeroBuilder get jediHero => + _$this._jediHero ??= new GAliasedHeroData_jediHeroBuilder(); + set jediHero(GAliasedHeroData_jediHeroBuilder? jediHero) => + _$this._jediHero = jediHero; + + GAliasedHeroDataBuilder() { + GAliasedHeroData._initializeBuilder(this); + } + + GAliasedHeroDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _empireHero = $v.empireHero?.toBuilder(); + _jediHero = $v.jediHero?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GAliasedHeroData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GAliasedHeroData; + } + + @override + void update(void Function(GAliasedHeroDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GAliasedHeroData build() => _build(); + + _$GAliasedHeroData _build() { + _$GAliasedHeroData _$result; + try { + _$result = _$v ?? + new _$GAliasedHeroData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GAliasedHeroData', 'G__typename'), + empireHero: _empireHero?.build(), + jediHero: _jediHero?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'empireHero'; + _empireHero?.build(); + _$failedField = 'jediHero'; + _jediHero?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GAliasedHeroData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GAliasedHeroData_empireHero extends GAliasedHeroData_empireHero { + @override + final String G__typename; + @override + final String id; + @override + final String name; + @override + final BuiltList<_i2.GEpisode?> from; + + factory _$GAliasedHeroData_empireHero( + [void Function(GAliasedHeroData_empireHeroBuilder)? updates]) => + (new GAliasedHeroData_empireHeroBuilder()..update(updates))._build(); + + _$GAliasedHeroData_empireHero._( + {required this.G__typename, + required this.id, + required this.name, + required this.from}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GAliasedHeroData_empireHero', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + id, r'GAliasedHeroData_empireHero', 'id'); + BuiltValueNullFieldError.checkNotNull( + name, r'GAliasedHeroData_empireHero', 'name'); + BuiltValueNullFieldError.checkNotNull( + from, r'GAliasedHeroData_empireHero', 'from'); + } + + @override + GAliasedHeroData_empireHero rebuild( + void Function(GAliasedHeroData_empireHeroBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GAliasedHeroData_empireHeroBuilder toBuilder() => + new GAliasedHeroData_empireHeroBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GAliasedHeroData_empireHero && + G__typename == other.G__typename && + id == other.id && + name == other.name && + from == other.from; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, from.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GAliasedHeroData_empireHero') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('name', name) + ..add('from', from)) + .toString(); + } +} + +class GAliasedHeroData_empireHeroBuilder + implements + Builder { + _$GAliasedHeroData_empireHero? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + ListBuilder<_i2.GEpisode?>? _from; + ListBuilder<_i2.GEpisode?> get from => + _$this._from ??= new ListBuilder<_i2.GEpisode?>(); + set from(ListBuilder<_i2.GEpisode?>? from) => _$this._from = from; + + GAliasedHeroData_empireHeroBuilder() { + GAliasedHeroData_empireHero._initializeBuilder(this); + } + + GAliasedHeroData_empireHeroBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _name = $v.name; + _from = $v.from.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GAliasedHeroData_empireHero other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GAliasedHeroData_empireHero; + } + + @override + void update(void Function(GAliasedHeroData_empireHeroBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GAliasedHeroData_empireHero build() => _build(); + + _$GAliasedHeroData_empireHero _build() { + _$GAliasedHeroData_empireHero _$result; + try { + _$result = _$v ?? + new _$GAliasedHeroData_empireHero._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GAliasedHeroData_empireHero', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GAliasedHeroData_empireHero', 'id'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GAliasedHeroData_empireHero', 'name'), + from: from.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'from'; + from.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GAliasedHeroData_empireHero', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GAliasedHeroData_jediHero extends GAliasedHeroData_jediHero { + @override + final String G__typename; + @override + final String id; + @override + final String name; + @override + final BuiltList<_i2.GEpisode?> from; + + factory _$GAliasedHeroData_jediHero( + [void Function(GAliasedHeroData_jediHeroBuilder)? updates]) => + (new GAliasedHeroData_jediHeroBuilder()..update(updates))._build(); + + _$GAliasedHeroData_jediHero._( + {required this.G__typename, + required this.id, + required this.name, + required this.from}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GAliasedHeroData_jediHero', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + id, r'GAliasedHeroData_jediHero', 'id'); + BuiltValueNullFieldError.checkNotNull( + name, r'GAliasedHeroData_jediHero', 'name'); + BuiltValueNullFieldError.checkNotNull( + from, r'GAliasedHeroData_jediHero', 'from'); + } + + @override + GAliasedHeroData_jediHero rebuild( + void Function(GAliasedHeroData_jediHeroBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GAliasedHeroData_jediHeroBuilder toBuilder() => + new GAliasedHeroData_jediHeroBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GAliasedHeroData_jediHero && + G__typename == other.G__typename && + id == other.id && + name == other.name && + from == other.from; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, from.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GAliasedHeroData_jediHero') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('name', name) + ..add('from', from)) + .toString(); + } +} + +class GAliasedHeroData_jediHeroBuilder + implements + Builder { + _$GAliasedHeroData_jediHero? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + ListBuilder<_i2.GEpisode?>? _from; + ListBuilder<_i2.GEpisode?> get from => + _$this._from ??= new ListBuilder<_i2.GEpisode?>(); + set from(ListBuilder<_i2.GEpisode?>? from) => _$this._from = from; + + GAliasedHeroData_jediHeroBuilder() { + GAliasedHeroData_jediHero._initializeBuilder(this); + } + + GAliasedHeroData_jediHeroBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _name = $v.name; + _from = $v.from.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GAliasedHeroData_jediHero other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GAliasedHeroData_jediHero; + } + + @override + void update(void Function(GAliasedHeroData_jediHeroBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GAliasedHeroData_jediHero build() => _build(); + + _$GAliasedHeroData_jediHero _build() { + _$GAliasedHeroData_jediHero _$result; + try { + _$result = _$v ?? + new _$GAliasedHeroData_jediHero._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GAliasedHeroData_jediHero', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GAliasedHeroData_jediHero', 'id'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GAliasedHeroData_jediHero', 'name'), + from: from.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'from'; + from.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GAliasedHeroData_jediHero', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.req.gql.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.req.gql.dart new file mode 100644 index 00000000..3927344f --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.req.gql.dart @@ -0,0 +1,44 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/aliases/__generated__/aliased_hero.ast.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/aliases/__generated__/aliased_hero.var.gql.dart' + as _i3; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'aliased_hero.req.gql.g.dart'; + +abstract class GAliasedHero + implements Built { + GAliasedHero._(); + + factory GAliasedHero([Function(GAliasedHeroBuilder b) updates]) = + _$GAliasedHero; + + static void _initializeBuilder(GAliasedHeroBuilder b) => b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'AliasedHero', + ); + + _i3.GAliasedHeroVars get vars; + _i1.Operation get operation; + static Serializer get serializer => _$gAliasedHeroSerializer; + + Map toJson() => (_i4.serializers.serializeWith( + GAliasedHero.serializer, + this, + ) as Map); + + static GAliasedHero? fromJson(Map json) => + _i4.serializers.deserializeWith( + GAliasedHero.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.req.gql.g.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.req.gql.g.dart new file mode 100644 index 00000000..3c44d30b --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.req.gql.g.dart @@ -0,0 +1,174 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'aliased_hero.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gAliasedHeroSerializer = + new _$GAliasedHeroSerializer(); + +class _$GAliasedHeroSerializer implements StructuredSerializer { + @override + final Iterable types = const [GAliasedHero, _$GAliasedHero]; + @override + final String wireName = 'GAliasedHero'; + + @override + Iterable serialize(Serializers serializers, GAliasedHero object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: const FullType(_i3.GAliasedHeroVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GAliasedHero deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GAliasedHeroBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'vars': + result.vars.replace(serializers.deserialize(value, + specifiedType: const FullType(_i3.GAliasedHeroVars))! + as _i3.GAliasedHeroVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GAliasedHero extends GAliasedHero { + @override + final _i3.GAliasedHeroVars vars; + @override + final _i1.Operation operation; + + factory _$GAliasedHero([void Function(GAliasedHeroBuilder)? updates]) => + (new GAliasedHeroBuilder()..update(updates))._build(); + + _$GAliasedHero._({required this.vars, required this.operation}) : super._() { + BuiltValueNullFieldError.checkNotNull(vars, r'GAliasedHero', 'vars'); + BuiltValueNullFieldError.checkNotNull( + operation, r'GAliasedHero', 'operation'); + } + + @override + GAliasedHero rebuild(void Function(GAliasedHeroBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GAliasedHeroBuilder toBuilder() => new GAliasedHeroBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GAliasedHero && + vars == other.vars && + operation == other.operation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GAliasedHero') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GAliasedHeroBuilder + implements Builder { + _$GAliasedHero? _$v; + + _i3.GAliasedHeroVarsBuilder? _vars; + _i3.GAliasedHeroVarsBuilder get vars => + _$this._vars ??= new _i3.GAliasedHeroVarsBuilder(); + set vars(_i3.GAliasedHeroVarsBuilder? vars) => _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GAliasedHeroBuilder() { + GAliasedHero._initializeBuilder(this); + } + + GAliasedHeroBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GAliasedHero other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GAliasedHero; + } + + @override + void update(void Function(GAliasedHeroBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GAliasedHero build() => _build(); + + _$GAliasedHero _build() { + _$GAliasedHero _$result; + try { + _$result = _$v ?? + new _$GAliasedHero._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull( + operation, r'GAliasedHero', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GAliasedHero', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.dart new file mode 100644 index 00000000..964f799a --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.dart @@ -0,0 +1,77 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart' + as _i1; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i2; + +part 'aliased_hero.var.gql.g.dart'; + +abstract class GAliasedHeroVars + implements Built { + GAliasedHeroVars._(); + + factory GAliasedHeroVars([Function(GAliasedHeroVarsBuilder b) updates]) = + _$GAliasedHeroVars; + + _i1.GEpisode get ep; + Map toJson() => (_i2.serializers.serializeWith( + GAliasedHeroVars.serializer, + this, + ) as Map); + + static GAliasedHeroVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GAliasedHeroVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GAliasedHeroVarsSerializer(); +} + +class GAliasedHeroVarsSerializer + extends StructuredSerializer { + final String wireName = 'GAliasedHeroVars'; + + final Iterable types = const [GAliasedHeroVars, _$GAliasedHeroVars]; + + Iterable serialize( + Serializers serializers, + GAliasedHeroVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('ep'); + result.add(serializers.serialize(object.ep, + specifiedType: const FullType(_i1.GEpisode))); + return result; + } + + GAliasedHeroVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GAliasedHeroVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'ep': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; + builder.ep = fieldValue; + break; + } + } + return builder.build(); + } +} diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.g.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.g.dart new file mode 100644 index 00000000..eb6a4801 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.g.dart @@ -0,0 +1,93 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'aliased_hero.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$GAliasedHeroVars extends GAliasedHeroVars { + @override + final _i1.GEpisode ep; + + factory _$GAliasedHeroVars( + [void Function(GAliasedHeroVarsBuilder)? updates]) => + (new GAliasedHeroVarsBuilder()..update(updates))._build(); + + _$GAliasedHeroVars._({required this.ep}) : super._() { + BuiltValueNullFieldError.checkNotNull(ep, r'GAliasedHeroVars', 'ep'); + } + + @override + GAliasedHeroVars rebuild(void Function(GAliasedHeroVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GAliasedHeroVarsBuilder toBuilder() => + new GAliasedHeroVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GAliasedHeroVars && ep == other.ep; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, ep.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GAliasedHeroVars')..add('ep', ep)) + .toString(); + } +} + +class GAliasedHeroVarsBuilder + implements Builder { + _$GAliasedHeroVars? _$v; + + _i1.GEpisode? _ep; + _i1.GEpisode? get ep => _$this._ep; + set ep(_i1.GEpisode? ep) => _$this._ep = ep; + + GAliasedHeroVarsBuilder(); + + GAliasedHeroVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _ep = $v.ep; + _$v = null; + } + return this; + } + + @override + void replace(GAliasedHeroVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GAliasedHeroVars; + } + + @override + void update(void Function(GAliasedHeroVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GAliasedHeroVars build() => _build(); + + _$GAliasedHeroVars _build() { + final _$result = _$v ?? + new _$GAliasedHeroVars._( + ep: BuiltValueNullFieldError.checkNotNull( + ep, r'GAliasedHeroVars', 'ep')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/aliases/alias_var_fragment.graphql b/codegen/end_to_end_test_tristate/lib/aliases/alias_var_fragment.graphql new file mode 100644 index 00000000..6d4edc61 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/alias_var_fragment.graphql @@ -0,0 +1,15 @@ +fragment PostFragment on Post { + id + isFavorited: favoritedUsers(where: {id: $userId}) { + totalCount + } + isLiked: likedUsers(where: {id: $userId}) { + totalCount + } +} + +query Posts($userId: ID!) { + posts(userId: $userId) { + ...PostFragment + } +} \ No newline at end of file diff --git a/codegen/end_to_end_test_tristate/lib/aliases/aliased_hero.graphql b/codegen/end_to_end_test_tristate/lib/aliases/aliased_hero.graphql new file mode 100644 index 00000000..49fdc5d1 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/aliases/aliased_hero.graphql @@ -0,0 +1,12 @@ +query AliasedHero($ep: Episode!) { + empireHero: hero(episode: EMPIRE) { + id + name + from: appearsIn + } + jediHero: hero(episode: JEDI) { + id + name + from: appearsIn + } +} diff --git a/codegen/end_to_end_test_tristate/lib/custom_field.dart b/codegen/end_to_end_test_tristate/lib/custom_field.dart new file mode 100644 index 00000000..a8ab62ba --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/custom_field.dart @@ -0,0 +1,31 @@ +import 'package:collection/collection.dart'; + +class CustomField { + String someString; + double someDouble; + Map someJSON; + + CustomField(this.someString, this.someDouble, this.someJSON); + + Map toJson() => { + 'someString': someString, + 'someDouble': someDouble, + 'someJSON': someJSON, + }; + + factory CustomField.fromJson(Map json) => CustomField( + json['someString'], + json['someDouble'], + json['someJSON'], + ); + + @override + bool operator ==(Object other) => + other is CustomField && + other.someString == this.someString && + other.someDouble == this.someDouble && + const DeepCollectionEquality().equals(other.someJSON, this.someJSON); + + @override + int get hashCode => DeepCollectionEquality().hash(toJson()); +} diff --git a/codegen/end_to_end_test_tristate/lib/custom_field_serializer.dart b/codegen/end_to_end_test_tristate/lib/custom_field_serializer.dart new file mode 100644 index 00000000..b28f8354 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/custom_field_serializer.dart @@ -0,0 +1,11 @@ +import 'package:gql_code_builder/src/serializers/json_serializer.dart'; + +import './custom_field.dart'; + +class CustomFieldSerializer extends JsonSerializer { + @override + CustomField fromJson(Map json) => CustomField.fromJson(json); + + @override + Map toJson(CustomField customField) => customField.toJson(); +} diff --git a/codegen/end_to_end_test_tristate/lib/date_serializer.dart b/codegen/end_to_end_test_tristate/lib/date_serializer.dart new file mode 100644 index 00000000..ce32fd13 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/date_serializer.dart @@ -0,0 +1,31 @@ +import 'package:built_value/serializer.dart'; + +class DateSerializer implements PrimitiveSerializer { + @override + DateTime deserialize( + Serializers serializers, + Object serialized, { + FullType specifiedType = FullType.unspecified, + }) { + if (!(serialized is int)) { + throw Exception( + "DateSerializer expected 'int' but got ${serialized.runtimeType}", + ); + } + return DateTime.fromMillisecondsSinceEpoch(serialized); + } + + @override + Object serialize( + Serializers serializers, + DateTime date, { + FullType specifiedType = FullType.unspecified, + }) => + date.millisecondsSinceEpoch; + + @override + Iterable get types => [DateTime]; + + @override + String get wireName => "Date"; +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.ast.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.ast.gql.dart new file mode 100644 index 00000000..2400af93 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.ast.gql.dart @@ -0,0 +1,88 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const PostFragmentForUser1 = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'PostFragmentForUser1'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Post'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'favoritedUsers'), + alias: null, + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'filter'), + value: _i1.ObjectValueNode(fields: [ + _i1.ObjectFieldNode( + name: _i1.NameNode(value: 'premium'), + value: _i1.BooleanValueNode(value: true), + ) + ]), + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'totalCount'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), + ), + ]), +); +const PostsWithFixedVariable = _i1.OperationDefinitionNode( + type: _i1.OperationType.query, + name: _i1.NameNode(value: 'PostsWithFixedVariable'), + variableDefinitions: [ + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'filter')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Json'), + isNonNull: false, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'posts'), + alias: null, + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'filter'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'filter')), + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'PostFragmentForUser1'), + directives: [], + ) + ]), + ) + ]), +); +const document = _i1.DocumentNode(definitions: [ + PostFragmentForUser1, + PostsWithFixedVariable, +]); diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.dart new file mode 100644 index 00000000..e0b8df54 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.dart @@ -0,0 +1,203 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'fragment_with_scalar_var.data.gql.g.dart'; + +abstract class GPostsWithFixedVariableData + implements + Built { + GPostsWithFixedVariableData._(); + + factory GPostsWithFixedVariableData( + [Function(GPostsWithFixedVariableDataBuilder b) updates]) = + _$GPostsWithFixedVariableData; + + static void _initializeBuilder(GPostsWithFixedVariableDataBuilder b) => + b..G__typename = 'Query'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + BuiltList? get posts; + static Serializer get serializer => + _$gPostsWithFixedVariableDataSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GPostsWithFixedVariableData.serializer, + this, + ) as Map); + + static GPostsWithFixedVariableData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GPostsWithFixedVariableData.serializer, + json, + ); +} + +abstract class GPostsWithFixedVariableData_posts + implements + Built, + GPostFragmentForUser1 { + GPostsWithFixedVariableData_posts._(); + + factory GPostsWithFixedVariableData_posts( + [Function(GPostsWithFixedVariableData_postsBuilder b) updates]) = + _$GPostsWithFixedVariableData_posts; + + static void _initializeBuilder(GPostsWithFixedVariableData_postsBuilder b) => + b..G__typename = 'Post'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get id; + @override + GPostsWithFixedVariableData_posts_favoritedUsers? get favoritedUsers; + static Serializer get serializer => + _$gPostsWithFixedVariableDataPostsSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GPostsWithFixedVariableData_posts.serializer, + this, + ) as Map); + + static GPostsWithFixedVariableData_posts? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GPostsWithFixedVariableData_posts.serializer, + json, + ); +} + +abstract class GPostsWithFixedVariableData_posts_favoritedUsers + implements + Built, + GPostFragmentForUser1_favoritedUsers { + GPostsWithFixedVariableData_posts_favoritedUsers._(); + + factory GPostsWithFixedVariableData_posts_favoritedUsers( + [Function(GPostsWithFixedVariableData_posts_favoritedUsersBuilder b) + updates]) = _$GPostsWithFixedVariableData_posts_favoritedUsers; + + static void _initializeBuilder( + GPostsWithFixedVariableData_posts_favoritedUsersBuilder b) => + b..G__typename = 'PostLikes'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + int get totalCount; + static Serializer + get serializer => + _$gPostsWithFixedVariableDataPostsFavoritedUsersSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GPostsWithFixedVariableData_posts_favoritedUsers.serializer, + this, + ) as Map); + + static GPostsWithFixedVariableData_posts_favoritedUsers? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GPostsWithFixedVariableData_posts_favoritedUsers.serializer, + json, + ); +} + +abstract class GPostFragmentForUser1 { + String get G__typename; + String get id; + GPostFragmentForUser1_favoritedUsers? get favoritedUsers; + Map toJson(); +} + +abstract class GPostFragmentForUser1_favoritedUsers { + String get G__typename; + int get totalCount; + Map toJson(); +} + +abstract class GPostFragmentForUser1Data + implements + Built, + GPostFragmentForUser1 { + GPostFragmentForUser1Data._(); + + factory GPostFragmentForUser1Data( + [Function(GPostFragmentForUser1DataBuilder b) updates]) = + _$GPostFragmentForUser1Data; + + static void _initializeBuilder(GPostFragmentForUser1DataBuilder b) => + b..G__typename = 'Post'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get id; + @override + GPostFragmentForUser1Data_favoritedUsers? get favoritedUsers; + static Serializer get serializer => + _$gPostFragmentForUser1DataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GPostFragmentForUser1Data.serializer, + this, + ) as Map); + + static GPostFragmentForUser1Data? fromJson(Map json) => + _i1.serializers.deserializeWith( + GPostFragmentForUser1Data.serializer, + json, + ); +} + +abstract class GPostFragmentForUser1Data_favoritedUsers + implements + Built, + GPostFragmentForUser1_favoritedUsers { + GPostFragmentForUser1Data_favoritedUsers._(); + + factory GPostFragmentForUser1Data_favoritedUsers( + [Function(GPostFragmentForUser1Data_favoritedUsersBuilder b) + updates]) = _$GPostFragmentForUser1Data_favoritedUsers; + + static void _initializeBuilder( + GPostFragmentForUser1Data_favoritedUsersBuilder b) => + b..G__typename = 'PostLikes'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + int get totalCount; + static Serializer get serializer => + _$gPostFragmentForUser1DataFavoritedUsersSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GPostFragmentForUser1Data_favoritedUsers.serializer, + this, + ) as Map); + + static GPostFragmentForUser1Data_favoritedUsers? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GPostFragmentForUser1Data_favoritedUsers.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.g.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.g.dart new file mode 100644 index 00000000..e5559c99 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.g.dart @@ -0,0 +1,955 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fragment_with_scalar_var.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer + _$gPostsWithFixedVariableDataSerializer = + new _$GPostsWithFixedVariableDataSerializer(); +Serializer + _$gPostsWithFixedVariableDataPostsSerializer = + new _$GPostsWithFixedVariableData_postsSerializer(); +Serializer + _$gPostsWithFixedVariableDataPostsFavoritedUsersSerializer = + new _$GPostsWithFixedVariableData_posts_favoritedUsersSerializer(); +Serializer _$gPostFragmentForUser1DataSerializer = + new _$GPostFragmentForUser1DataSerializer(); +Serializer + _$gPostFragmentForUser1DataFavoritedUsersSerializer = + new _$GPostFragmentForUser1Data_favoritedUsersSerializer(); + +class _$GPostsWithFixedVariableDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GPostsWithFixedVariableData, + _$GPostsWithFixedVariableData + ]; + @override + final String wireName = 'GPostsWithFixedVariableData'; + + @override + Iterable serialize( + Serializers serializers, GPostsWithFixedVariableData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.posts; + if (value != null) { + result + ..add('posts') + ..add(serializers.serialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable(GPostsWithFixedVariableData_posts) + ]))); + } + return result; + } + + @override + GPostsWithFixedVariableData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostsWithFixedVariableDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'posts': + result.posts.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable(GPostsWithFixedVariableData_posts) + ]))! as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$GPostsWithFixedVariableData_postsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GPostsWithFixedVariableData_posts, + _$GPostsWithFixedVariableData_posts + ]; + @override + final String wireName = 'GPostsWithFixedVariableData_posts'; + + @override + Iterable serialize( + Serializers serializers, GPostsWithFixedVariableData_posts object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.favoritedUsers; + if (value != null) { + result + ..add('favoritedUsers') + ..add(serializers.serialize(value, + specifiedType: const FullType( + GPostsWithFixedVariableData_posts_favoritedUsers))); + } + return result; + } + + @override + GPostsWithFixedVariableData_posts deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostsWithFixedVariableData_postsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'favoritedUsers': + result.favoritedUsers.replace(serializers.deserialize(value, + specifiedType: const FullType( + GPostsWithFixedVariableData_posts_favoritedUsers))! + as GPostsWithFixedVariableData_posts_favoritedUsers); + break; + } + } + + return result.build(); + } +} + +class _$GPostsWithFixedVariableData_posts_favoritedUsersSerializer + implements + StructuredSerializer { + @override + final Iterable types = const [ + GPostsWithFixedVariableData_posts_favoritedUsers, + _$GPostsWithFixedVariableData_posts_favoritedUsers + ]; + @override + final String wireName = 'GPostsWithFixedVariableData_posts_favoritedUsers'; + + @override + Iterable serialize(Serializers serializers, + GPostsWithFixedVariableData_posts_favoritedUsers object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'totalCount', + serializers.serialize(object.totalCount, + specifiedType: const FullType(int)), + ]; + + return result; + } + + @override + GPostsWithFixedVariableData_posts_favoritedUsers deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = + new GPostsWithFixedVariableData_posts_favoritedUsersBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'totalCount': + result.totalCount = serializers.deserialize(value, + specifiedType: const FullType(int))! as int; + break; + } + } + + return result.build(); + } +} + +class _$GPostFragmentForUser1DataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GPostFragmentForUser1Data, + _$GPostFragmentForUser1Data + ]; + @override + final String wireName = 'GPostFragmentForUser1Data'; + + @override + Iterable serialize( + Serializers serializers, GPostFragmentForUser1Data object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.favoritedUsers; + if (value != null) { + result + ..add('favoritedUsers') + ..add(serializers.serialize(value, + specifiedType: + const FullType(GPostFragmentForUser1Data_favoritedUsers))); + } + return result; + } + + @override + GPostFragmentForUser1Data deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostFragmentForUser1DataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'favoritedUsers': + result.favoritedUsers.replace(serializers.deserialize(value, + specifiedType: + const FullType(GPostFragmentForUser1Data_favoritedUsers))! + as GPostFragmentForUser1Data_favoritedUsers); + break; + } + } + + return result.build(); + } +} + +class _$GPostFragmentForUser1Data_favoritedUsersSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GPostFragmentForUser1Data_favoritedUsers, + _$GPostFragmentForUser1Data_favoritedUsers + ]; + @override + final String wireName = 'GPostFragmentForUser1Data_favoritedUsers'; + + @override + Iterable serialize( + Serializers serializers, GPostFragmentForUser1Data_favoritedUsers object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'totalCount', + serializers.serialize(object.totalCount, + specifiedType: const FullType(int)), + ]; + + return result; + } + + @override + GPostFragmentForUser1Data_favoritedUsers deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostFragmentForUser1Data_favoritedUsersBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'totalCount': + result.totalCount = serializers.deserialize(value, + specifiedType: const FullType(int))! as int; + break; + } + } + + return result.build(); + } +} + +class _$GPostsWithFixedVariableData extends GPostsWithFixedVariableData { + @override + final String G__typename; + @override + final BuiltList? posts; + + factory _$GPostsWithFixedVariableData( + [void Function(GPostsWithFixedVariableDataBuilder)? updates]) => + (new GPostsWithFixedVariableDataBuilder()..update(updates))._build(); + + _$GPostsWithFixedVariableData._({required this.G__typename, this.posts}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostsWithFixedVariableData', 'G__typename'); + } + + @override + GPostsWithFixedVariableData rebuild( + void Function(GPostsWithFixedVariableDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostsWithFixedVariableDataBuilder toBuilder() => + new GPostsWithFixedVariableDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostsWithFixedVariableData && + G__typename == other.G__typename && + posts == other.posts; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, posts.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostsWithFixedVariableData') + ..add('G__typename', G__typename) + ..add('posts', posts)) + .toString(); + } +} + +class GPostsWithFixedVariableDataBuilder + implements + Builder { + _$GPostsWithFixedVariableData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + ListBuilder? _posts; + ListBuilder get posts => + _$this._posts ??= new ListBuilder(); + set posts(ListBuilder? posts) => + _$this._posts = posts; + + GPostsWithFixedVariableDataBuilder() { + GPostsWithFixedVariableData._initializeBuilder(this); + } + + GPostsWithFixedVariableDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _posts = $v.posts?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GPostsWithFixedVariableData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostsWithFixedVariableData; + } + + @override + void update(void Function(GPostsWithFixedVariableDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostsWithFixedVariableData build() => _build(); + + _$GPostsWithFixedVariableData _build() { + _$GPostsWithFixedVariableData _$result; + try { + _$result = _$v ?? + new _$GPostsWithFixedVariableData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostsWithFixedVariableData', 'G__typename'), + posts: _posts?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'posts'; + _posts?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GPostsWithFixedVariableData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GPostsWithFixedVariableData_posts + extends GPostsWithFixedVariableData_posts { + @override + final String G__typename; + @override + final String id; + @override + final GPostsWithFixedVariableData_posts_favoritedUsers? favoritedUsers; + + factory _$GPostsWithFixedVariableData_posts( + [void Function(GPostsWithFixedVariableData_postsBuilder)? updates]) => + (new GPostsWithFixedVariableData_postsBuilder()..update(updates)) + ._build(); + + _$GPostsWithFixedVariableData_posts._( + {required this.G__typename, required this.id, this.favoritedUsers}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostsWithFixedVariableData_posts', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + id, r'GPostsWithFixedVariableData_posts', 'id'); + } + + @override + GPostsWithFixedVariableData_posts rebuild( + void Function(GPostsWithFixedVariableData_postsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostsWithFixedVariableData_postsBuilder toBuilder() => + new GPostsWithFixedVariableData_postsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostsWithFixedVariableData_posts && + G__typename == other.G__typename && + id == other.id && + favoritedUsers == other.favoritedUsers; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, favoritedUsers.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostsWithFixedVariableData_posts') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('favoritedUsers', favoritedUsers)) + .toString(); + } +} + +class GPostsWithFixedVariableData_postsBuilder + implements + Builder { + _$GPostsWithFixedVariableData_posts? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + GPostsWithFixedVariableData_posts_favoritedUsersBuilder? _favoritedUsers; + GPostsWithFixedVariableData_posts_favoritedUsersBuilder get favoritedUsers => + _$this._favoritedUsers ??= + new GPostsWithFixedVariableData_posts_favoritedUsersBuilder(); + set favoritedUsers( + GPostsWithFixedVariableData_posts_favoritedUsersBuilder? + favoritedUsers) => + _$this._favoritedUsers = favoritedUsers; + + GPostsWithFixedVariableData_postsBuilder() { + GPostsWithFixedVariableData_posts._initializeBuilder(this); + } + + GPostsWithFixedVariableData_postsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _favoritedUsers = $v.favoritedUsers?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GPostsWithFixedVariableData_posts other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostsWithFixedVariableData_posts; + } + + @override + void update( + void Function(GPostsWithFixedVariableData_postsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostsWithFixedVariableData_posts build() => _build(); + + _$GPostsWithFixedVariableData_posts _build() { + _$GPostsWithFixedVariableData_posts _$result; + try { + _$result = _$v ?? + new _$GPostsWithFixedVariableData_posts._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GPostsWithFixedVariableData_posts', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GPostsWithFixedVariableData_posts', 'id'), + favoritedUsers: _favoritedUsers?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'favoritedUsers'; + _favoritedUsers?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GPostsWithFixedVariableData_posts', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GPostsWithFixedVariableData_posts_favoritedUsers + extends GPostsWithFixedVariableData_posts_favoritedUsers { + @override + final String G__typename; + @override + final int totalCount; + + factory _$GPostsWithFixedVariableData_posts_favoritedUsers( + [void Function( + GPostsWithFixedVariableData_posts_favoritedUsersBuilder)? + updates]) => + (new GPostsWithFixedVariableData_posts_favoritedUsersBuilder() + ..update(updates)) + ._build(); + + _$GPostsWithFixedVariableData_posts_favoritedUsers._( + {required this.G__typename, required this.totalCount}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GPostsWithFixedVariableData_posts_favoritedUsers', 'G__typename'); + BuiltValueNullFieldError.checkNotNull(totalCount, + r'GPostsWithFixedVariableData_posts_favoritedUsers', 'totalCount'); + } + + @override + GPostsWithFixedVariableData_posts_favoritedUsers rebuild( + void Function(GPostsWithFixedVariableData_posts_favoritedUsersBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostsWithFixedVariableData_posts_favoritedUsersBuilder toBuilder() => + new GPostsWithFixedVariableData_posts_favoritedUsersBuilder() + ..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostsWithFixedVariableData_posts_favoritedUsers && + G__typename == other.G__typename && + totalCount == other.totalCount; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, totalCount.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GPostsWithFixedVariableData_posts_favoritedUsers') + ..add('G__typename', G__typename) + ..add('totalCount', totalCount)) + .toString(); + } +} + +class GPostsWithFixedVariableData_posts_favoritedUsersBuilder + implements + Builder { + _$GPostsWithFixedVariableData_posts_favoritedUsers? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + int? _totalCount; + int? get totalCount => _$this._totalCount; + set totalCount(int? totalCount) => _$this._totalCount = totalCount; + + GPostsWithFixedVariableData_posts_favoritedUsersBuilder() { + GPostsWithFixedVariableData_posts_favoritedUsers._initializeBuilder(this); + } + + GPostsWithFixedVariableData_posts_favoritedUsersBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _totalCount = $v.totalCount; + _$v = null; + } + return this; + } + + @override + void replace(GPostsWithFixedVariableData_posts_favoritedUsers other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostsWithFixedVariableData_posts_favoritedUsers; + } + + @override + void update( + void Function(GPostsWithFixedVariableData_posts_favoritedUsersBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GPostsWithFixedVariableData_posts_favoritedUsers build() => _build(); + + _$GPostsWithFixedVariableData_posts_favoritedUsers _build() { + final _$result = _$v ?? + new _$GPostsWithFixedVariableData_posts_favoritedUsers._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, + r'GPostsWithFixedVariableData_posts_favoritedUsers', + 'G__typename'), + totalCount: BuiltValueNullFieldError.checkNotNull( + totalCount, + r'GPostsWithFixedVariableData_posts_favoritedUsers', + 'totalCount')); + replace(_$result); + return _$result; + } +} + +class _$GPostFragmentForUser1Data extends GPostFragmentForUser1Data { + @override + final String G__typename; + @override + final String id; + @override + final GPostFragmentForUser1Data_favoritedUsers? favoritedUsers; + + factory _$GPostFragmentForUser1Data( + [void Function(GPostFragmentForUser1DataBuilder)? updates]) => + (new GPostFragmentForUser1DataBuilder()..update(updates))._build(); + + _$GPostFragmentForUser1Data._( + {required this.G__typename, required this.id, this.favoritedUsers}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostFragmentForUser1Data', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + id, r'GPostFragmentForUser1Data', 'id'); + } + + @override + GPostFragmentForUser1Data rebuild( + void Function(GPostFragmentForUser1DataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostFragmentForUser1DataBuilder toBuilder() => + new GPostFragmentForUser1DataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostFragmentForUser1Data && + G__typename == other.G__typename && + id == other.id && + favoritedUsers == other.favoritedUsers; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, favoritedUsers.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostFragmentForUser1Data') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('favoritedUsers', favoritedUsers)) + .toString(); + } +} + +class GPostFragmentForUser1DataBuilder + implements + Builder { + _$GPostFragmentForUser1Data? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + GPostFragmentForUser1Data_favoritedUsersBuilder? _favoritedUsers; + GPostFragmentForUser1Data_favoritedUsersBuilder get favoritedUsers => + _$this._favoritedUsers ??= + new GPostFragmentForUser1Data_favoritedUsersBuilder(); + set favoritedUsers( + GPostFragmentForUser1Data_favoritedUsersBuilder? favoritedUsers) => + _$this._favoritedUsers = favoritedUsers; + + GPostFragmentForUser1DataBuilder() { + GPostFragmentForUser1Data._initializeBuilder(this); + } + + GPostFragmentForUser1DataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _favoritedUsers = $v.favoritedUsers?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GPostFragmentForUser1Data other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostFragmentForUser1Data; + } + + @override + void update(void Function(GPostFragmentForUser1DataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostFragmentForUser1Data build() => _build(); + + _$GPostFragmentForUser1Data _build() { + _$GPostFragmentForUser1Data _$result; + try { + _$result = _$v ?? + new _$GPostFragmentForUser1Data._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostFragmentForUser1Data', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GPostFragmentForUser1Data', 'id'), + favoritedUsers: _favoritedUsers?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'favoritedUsers'; + _favoritedUsers?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GPostFragmentForUser1Data', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GPostFragmentForUser1Data_favoritedUsers + extends GPostFragmentForUser1Data_favoritedUsers { + @override + final String G__typename; + @override + final int totalCount; + + factory _$GPostFragmentForUser1Data_favoritedUsers( + [void Function(GPostFragmentForUser1Data_favoritedUsersBuilder)? + updates]) => + (new GPostFragmentForUser1Data_favoritedUsersBuilder()..update(updates)) + ._build(); + + _$GPostFragmentForUser1Data_favoritedUsers._( + {required this.G__typename, required this.totalCount}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GPostFragmentForUser1Data_favoritedUsers', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + totalCount, r'GPostFragmentForUser1Data_favoritedUsers', 'totalCount'); + } + + @override + GPostFragmentForUser1Data_favoritedUsers rebuild( + void Function(GPostFragmentForUser1Data_favoritedUsersBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostFragmentForUser1Data_favoritedUsersBuilder toBuilder() => + new GPostFragmentForUser1Data_favoritedUsersBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostFragmentForUser1Data_favoritedUsers && + G__typename == other.G__typename && + totalCount == other.totalCount; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, totalCount.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GPostFragmentForUser1Data_favoritedUsers') + ..add('G__typename', G__typename) + ..add('totalCount', totalCount)) + .toString(); + } +} + +class GPostFragmentForUser1Data_favoritedUsersBuilder + implements + Builder { + _$GPostFragmentForUser1Data_favoritedUsers? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + int? _totalCount; + int? get totalCount => _$this._totalCount; + set totalCount(int? totalCount) => _$this._totalCount = totalCount; + + GPostFragmentForUser1Data_favoritedUsersBuilder() { + GPostFragmentForUser1Data_favoritedUsers._initializeBuilder(this); + } + + GPostFragmentForUser1Data_favoritedUsersBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _totalCount = $v.totalCount; + _$v = null; + } + return this; + } + + @override + void replace(GPostFragmentForUser1Data_favoritedUsers other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostFragmentForUser1Data_favoritedUsers; + } + + @override + void update( + void Function(GPostFragmentForUser1Data_favoritedUsersBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostFragmentForUser1Data_favoritedUsers build() => _build(); + + _$GPostFragmentForUser1Data_favoritedUsers _build() { + final _$result = _$v ?? + new _$GPostFragmentForUser1Data_favoritedUsers._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GPostFragmentForUser1Data_favoritedUsers', 'G__typename'), + totalCount: BuiltValueNullFieldError.checkNotNull(totalCount, + r'GPostFragmentForUser1Data_favoritedUsers', 'totalCount')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.req.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.req.gql.dart new file mode 100644 index 00000000..f4a8abda --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.req.gql.dart @@ -0,0 +1,46 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/fragments/__generated__/fragment_with_scalar_var.ast.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/fragments/__generated__/fragment_with_scalar_var.var.gql.dart' + as _i3; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'fragment_with_scalar_var.req.gql.g.dart'; + +abstract class GPostsWithFixedVariable + implements Built { + GPostsWithFixedVariable._(); + + factory GPostsWithFixedVariable( + [Function(GPostsWithFixedVariableBuilder b) updates]) = + _$GPostsWithFixedVariable; + + static void _initializeBuilder(GPostsWithFixedVariableBuilder b) => b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'PostsWithFixedVariable', + ); + + _i3.GPostsWithFixedVariableVars get vars; + _i1.Operation get operation; + static Serializer get serializer => + _$gPostsWithFixedVariableSerializer; + + Map toJson() => (_i4.serializers.serializeWith( + GPostsWithFixedVariable.serializer, + this, + ) as Map); + + static GPostsWithFixedVariable? fromJson(Map json) => + _i4.serializers.deserializeWith( + GPostsWithFixedVariable.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.req.gql.g.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.req.gql.g.dart new file mode 100644 index 00000000..49c53e4e --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.req.gql.g.dart @@ -0,0 +1,186 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fragment_with_scalar_var.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gPostsWithFixedVariableSerializer = + new _$GPostsWithFixedVariableSerializer(); + +class _$GPostsWithFixedVariableSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GPostsWithFixedVariable, + _$GPostsWithFixedVariable + ]; + @override + final String wireName = 'GPostsWithFixedVariable'; + + @override + Iterable serialize( + Serializers serializers, GPostsWithFixedVariable object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: const FullType(_i3.GPostsWithFixedVariableVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GPostsWithFixedVariable deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GPostsWithFixedVariableBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'vars': + result.vars.replace(serializers.deserialize(value, + specifiedType: + const FullType(_i3.GPostsWithFixedVariableVars))! + as _i3.GPostsWithFixedVariableVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GPostsWithFixedVariable extends GPostsWithFixedVariable { + @override + final _i3.GPostsWithFixedVariableVars vars; + @override + final _i1.Operation operation; + + factory _$GPostsWithFixedVariable( + [void Function(GPostsWithFixedVariableBuilder)? updates]) => + (new GPostsWithFixedVariableBuilder()..update(updates))._build(); + + _$GPostsWithFixedVariable._({required this.vars, required this.operation}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + vars, r'GPostsWithFixedVariable', 'vars'); + BuiltValueNullFieldError.checkNotNull( + operation, r'GPostsWithFixedVariable', 'operation'); + } + + @override + GPostsWithFixedVariable rebuild( + void Function(GPostsWithFixedVariableBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostsWithFixedVariableBuilder toBuilder() => + new GPostsWithFixedVariableBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostsWithFixedVariable && + vars == other.vars && + operation == other.operation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostsWithFixedVariable') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GPostsWithFixedVariableBuilder + implements + Builder { + _$GPostsWithFixedVariable? _$v; + + _i3.GPostsWithFixedVariableVarsBuilder? _vars; + _i3.GPostsWithFixedVariableVarsBuilder get vars => + _$this._vars ??= new _i3.GPostsWithFixedVariableVarsBuilder(); + set vars(_i3.GPostsWithFixedVariableVarsBuilder? vars) => _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GPostsWithFixedVariableBuilder() { + GPostsWithFixedVariable._initializeBuilder(this); + } + + GPostsWithFixedVariableBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GPostsWithFixedVariable other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostsWithFixedVariable; + } + + @override + void update(void Function(GPostsWithFixedVariableBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostsWithFixedVariable build() => _build(); + + _$GPostsWithFixedVariable _build() { + _$GPostsWithFixedVariable _$result; + try { + _$result = _$v ?? + new _$GPostsWithFixedVariable._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull( + operation, r'GPostsWithFixedVariable', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GPostsWithFixedVariable', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart new file mode 100644 index 00000000..f99413c0 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart @@ -0,0 +1,140 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i3; +import 'package:gql_exec/value.dart' as _i1; + +part 'fragment_with_scalar_var.var.gql.g.dart'; + +abstract class GPostsWithFixedVariableVars + implements + Built { + GPostsWithFixedVariableVars._(); + + factory GPostsWithFixedVariableVars( + [Function(GPostsWithFixedVariableVarsBuilder b) updates]) = + _$GPostsWithFixedVariableVars; + + static void _initializeBuilder(GPostsWithFixedVariableVarsBuilder b) => + b..filter = const _i1.AbsentValue(); + + _i1.Value<_i2.GJson>? get filter; + Map toJson() => (_i3.serializers.serializeWith( + GPostsWithFixedVariableVars.serializer, + this, + ) as Map); + + static GPostsWithFixedVariableVars? fromJson(Map json) => + _i3.serializers.deserializeWith( + GPostsWithFixedVariableVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GPostsWithFixedVariableVarsSerializer(); +} + +abstract class GPostFragmentForUser1Vars + implements + Built { + GPostFragmentForUser1Vars._(); + + factory GPostFragmentForUser1Vars( + [Function(GPostFragmentForUser1VarsBuilder b) updates]) = + _$GPostFragmentForUser1Vars; + + Map toJson() => (_i3.serializers.serializeWith( + GPostFragmentForUser1Vars.serializer, + this, + ) as Map); + + static GPostFragmentForUser1Vars? fromJson(Map json) => + _i3.serializers.deserializeWith( + GPostFragmentForUser1Vars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GPostFragmentForUser1VarsSerializer(); +} + +class GPostsWithFixedVariableVarsSerializer + extends StructuredSerializer { + final String wireName = 'GPostsWithFixedVariableVars'; + + final Iterable types = const [ + GPostsWithFixedVariableVars, + _$GPostsWithFixedVariableVars + ]; + + Iterable serialize( + Serializers serializers, + GPostsWithFixedVariableVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + final _$filtervalue = object.filter; + if (_$filtervalue case _i1.PresentValue(value: final _$value)) { + result.add('filter'); + result.add(serializers.serialize(_$value, + specifiedType: const FullType(_i2.GJson))); + } + return result; + } + + GPostsWithFixedVariableVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GPostsWithFixedVariableVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'filter': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i2.GJson)) as _i2.GJson; + builder.filter = _i1.PresentValue(fieldValue); + break; + } + } + return builder.build(); + } +} + +class GPostFragmentForUser1VarsSerializer + extends StructuredSerializer { + final String wireName = 'GPostFragmentForUser1Vars'; + + final Iterable types = const [ + GPostFragmentForUser1Vars, + _$GPostFragmentForUser1Vars + ]; + + Iterable serialize( + Serializers serializers, + GPostFragmentForUser1Vars object, { + FullType specifiedType = FullType.unspecified, + }) { + return const []; + } + + GPostFragmentForUser1Vars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + return GPostFragmentForUser1Vars(); + } +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.g.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.g.dart new file mode 100644 index 00000000..3bb7c025 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.g.dart @@ -0,0 +1,155 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fragment_with_scalar_var.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$GPostsWithFixedVariableVars extends GPostsWithFixedVariableVars { + @override + final _i1.Value<_i2.GJson>? filter; + + factory _$GPostsWithFixedVariableVars( + [void Function(GPostsWithFixedVariableVarsBuilder)? updates]) => + (new GPostsWithFixedVariableVarsBuilder()..update(updates))._build(); + + _$GPostsWithFixedVariableVars._({this.filter}) : super._(); + + @override + GPostsWithFixedVariableVars rebuild( + void Function(GPostsWithFixedVariableVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostsWithFixedVariableVarsBuilder toBuilder() => + new GPostsWithFixedVariableVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostsWithFixedVariableVars && filter == other.filter; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, filter.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostsWithFixedVariableVars') + ..add('filter', filter)) + .toString(); + } +} + +class GPostsWithFixedVariableVarsBuilder + implements + Builder { + _$GPostsWithFixedVariableVars? _$v; + + _i1.Value<_i2.GJson>? _filter; + _i1.Value<_i2.GJson>? get filter => _$this._filter; + set filter(_i1.Value<_i2.GJson>? filter) => _$this._filter = filter; + + GPostsWithFixedVariableVarsBuilder() { + GPostsWithFixedVariableVars._initializeBuilder(this); + } + + GPostsWithFixedVariableVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _filter = $v.filter; + _$v = null; + } + return this; + } + + @override + void replace(GPostsWithFixedVariableVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostsWithFixedVariableVars; + } + + @override + void update(void Function(GPostsWithFixedVariableVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostsWithFixedVariableVars build() => _build(); + + _$GPostsWithFixedVariableVars _build() { + final _$result = _$v ?? new _$GPostsWithFixedVariableVars._(filter: filter); + replace(_$result); + return _$result; + } +} + +class _$GPostFragmentForUser1Vars extends GPostFragmentForUser1Vars { + factory _$GPostFragmentForUser1Vars( + [void Function(GPostFragmentForUser1VarsBuilder)? updates]) => + (new GPostFragmentForUser1VarsBuilder()..update(updates))._build(); + + _$GPostFragmentForUser1Vars._() : super._(); + + @override + GPostFragmentForUser1Vars rebuild( + void Function(GPostFragmentForUser1VarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostFragmentForUser1VarsBuilder toBuilder() => + new GPostFragmentForUser1VarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostFragmentForUser1Vars; + } + + @override + int get hashCode { + return 10256085; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GPostFragmentForUser1Vars').toString(); + } +} + +class GPostFragmentForUser1VarsBuilder + implements + Builder { + _$GPostFragmentForUser1Vars? _$v; + + GPostFragmentForUser1VarsBuilder(); + + @override + void replace(GPostFragmentForUser1Vars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostFragmentForUser1Vars; + } + + @override + void update(void Function(GPostFragmentForUser1VarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostFragmentForUser1Vars build() => _build(); + + _$GPostFragmentForUser1Vars _build() { + final _$result = _$v ?? new _$GPostFragmentForUser1Vars._(); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.ast.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.ast.gql.dart new file mode 100644 index 00000000..23dc23b0 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.ast.gql.dart @@ -0,0 +1,126 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const HeroWithFragments = _i1.OperationDefinitionNode( + type: _i1.OperationType.query, + name: _i1.NameNode(value: 'HeroWithFragments'), + variableDefinitions: [ + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'first')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: false, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'hero'), + alias: null, + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'episode'), + value: _i1.EnumValueNode(name: _i1.NameNode(value: 'JEDI')), + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'comparisonFields'), + directives: [], + ) + ]), + ) + ]), +); +const heroData = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'heroData'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), +); +const comparisonFields = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'comparisonFields'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'heroData'), + directives: [], + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'friendsConnection'), + alias: null, + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'first'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'first')), + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'totalCount'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'edges'), + alias: null, + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'node'), + alias: null, + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'heroData'), + directives: [], + ) + ]), + ) + ]), + ), + ]), + ), + ]), +); +const document = _i1.DocumentNode(definitions: [ + HeroWithFragments, + heroData, + comparisonFields, +]); diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.data.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.data.gql.dart new file mode 100644 index 00000000..5c53a18b --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.data.gql.dart @@ -0,0 +1,419 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'hero_with_fragments.data.gql.g.dart'; + +abstract class GHeroWithFragmentsData + implements Built { + GHeroWithFragmentsData._(); + + factory GHeroWithFragmentsData( + [Function(GHeroWithFragmentsDataBuilder b) updates]) = + _$GHeroWithFragmentsData; + + static void _initializeBuilder(GHeroWithFragmentsDataBuilder b) => + b..G__typename = 'Query'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + GHeroWithFragmentsData_hero? get hero; + static Serializer get serializer => + _$gHeroWithFragmentsDataSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GHeroWithFragmentsData.serializer, + this, + ) as Map); + + static GHeroWithFragmentsData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GHeroWithFragmentsData.serializer, + json, + ); +} + +abstract class GHeroWithFragmentsData_hero + implements + Built, + GcomparisonFields { + GHeroWithFragmentsData_hero._(); + + factory GHeroWithFragmentsData_hero( + [Function(GHeroWithFragmentsData_heroBuilder b) updates]) = + _$GHeroWithFragmentsData_hero; + + static void _initializeBuilder(GHeroWithFragmentsData_heroBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get id; + @override + GHeroWithFragmentsData_hero_friendsConnection get friendsConnection; + @override + String get name; + static Serializer get serializer => + _$gHeroWithFragmentsDataHeroSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GHeroWithFragmentsData_hero.serializer, + this, + ) as Map); + + static GHeroWithFragmentsData_hero? fromJson(Map json) => + _i1.serializers.deserializeWith( + GHeroWithFragmentsData_hero.serializer, + json, + ); +} + +abstract class GHeroWithFragmentsData_hero_friendsConnection + implements + Built, + GcomparisonFields_friendsConnection { + GHeroWithFragmentsData_hero_friendsConnection._(); + + factory GHeroWithFragmentsData_hero_friendsConnection( + [Function(GHeroWithFragmentsData_hero_friendsConnectionBuilder b) + updates]) = _$GHeroWithFragmentsData_hero_friendsConnection; + + static void _initializeBuilder( + GHeroWithFragmentsData_hero_friendsConnectionBuilder b) => + b..G__typename = 'FriendsConnection'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + int? get totalCount; + @override + BuiltList? get edges; + static Serializer + get serializer => _$gHeroWithFragmentsDataHeroFriendsConnectionSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GHeroWithFragmentsData_hero_friendsConnection.serializer, + this, + ) as Map); + + static GHeroWithFragmentsData_hero_friendsConnection? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GHeroWithFragmentsData_hero_friendsConnection.serializer, + json, + ); +} + +abstract class GHeroWithFragmentsData_hero_friendsConnection_edges + implements + Built, + GcomparisonFields_friendsConnection_edges { + GHeroWithFragmentsData_hero_friendsConnection_edges._(); + + factory GHeroWithFragmentsData_hero_friendsConnection_edges( + [Function(GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder b) + updates]) = _$GHeroWithFragmentsData_hero_friendsConnection_edges; + + static void _initializeBuilder( + GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder b) => + b..G__typename = 'FriendsEdge'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + GHeroWithFragmentsData_hero_friendsConnection_edges_node? get node; + static Serializer + get serializer => + _$gHeroWithFragmentsDataHeroFriendsConnectionEdgesSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GHeroWithFragmentsData_hero_friendsConnection_edges.serializer, + this, + ) as Map); + + static GHeroWithFragmentsData_hero_friendsConnection_edges? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GHeroWithFragmentsData_hero_friendsConnection_edges.serializer, + json, + ); +} + +abstract class GHeroWithFragmentsData_hero_friendsConnection_edges_node + implements + Built, + GcomparisonFields_friendsConnection_edges_node, + GheroData { + GHeroWithFragmentsData_hero_friendsConnection_edges_node._(); + + factory GHeroWithFragmentsData_hero_friendsConnection_edges_node( + [Function( + GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder b) + updates]) = _$GHeroWithFragmentsData_hero_friendsConnection_edges_node; + + static void _initializeBuilder( + GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get name; + static Serializer + get serializer => + _$gHeroWithFragmentsDataHeroFriendsConnectionEdgesNodeSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GHeroWithFragmentsData_hero_friendsConnection_edges_node.serializer, + this, + ) as Map); + + static GHeroWithFragmentsData_hero_friendsConnection_edges_node? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GHeroWithFragmentsData_hero_friendsConnection_edges_node.serializer, + json, + ); +} + +abstract class GheroData { + String get G__typename; + String get name; + Map toJson(); +} + +abstract class GheroDataData + implements Built, GheroData { + GheroDataData._(); + + factory GheroDataData([Function(GheroDataDataBuilder b) updates]) = + _$GheroDataData; + + static void _initializeBuilder(GheroDataDataBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get name; + static Serializer get serializer => _$gheroDataDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GheroDataData.serializer, + this, + ) as Map); + + static GheroDataData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GheroDataData.serializer, + json, + ); +} + +abstract class GcomparisonFields implements GheroData { + @override + String get G__typename; + String get id; + @override + String get name; + GcomparisonFields_friendsConnection get friendsConnection; + @override + Map toJson(); +} + +abstract class GcomparisonFields_friendsConnection { + String get G__typename; + int? get totalCount; + BuiltList? get edges; + Map toJson(); +} + +abstract class GcomparisonFields_friendsConnection_edges { + String get G__typename; + GcomparisonFields_friendsConnection_edges_node? get node; + Map toJson(); +} + +abstract class GcomparisonFields_friendsConnection_edges_node + implements GheroData { + @override + String get G__typename; + @override + String get name; + @override + Map toJson(); +} + +abstract class GcomparisonFieldsData + implements + Built, + GcomparisonFields, + GheroData { + GcomparisonFieldsData._(); + + factory GcomparisonFieldsData( + [Function(GcomparisonFieldsDataBuilder b) updates]) = + _$GcomparisonFieldsData; + + static void _initializeBuilder(GcomparisonFieldsDataBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get id; + @override + String get name; + @override + GcomparisonFieldsData_friendsConnection get friendsConnection; + static Serializer get serializer => + _$gcomparisonFieldsDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GcomparisonFieldsData.serializer, + this, + ) as Map); + + static GcomparisonFieldsData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GcomparisonFieldsData.serializer, + json, + ); +} + +abstract class GcomparisonFieldsData_friendsConnection + implements + Built, + GcomparisonFields_friendsConnection { + GcomparisonFieldsData_friendsConnection._(); + + factory GcomparisonFieldsData_friendsConnection( + [Function(GcomparisonFieldsData_friendsConnectionBuilder b) + updates]) = _$GcomparisonFieldsData_friendsConnection; + + static void _initializeBuilder( + GcomparisonFieldsData_friendsConnectionBuilder b) => + b..G__typename = 'FriendsConnection'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + int? get totalCount; + @override + BuiltList? get edges; + static Serializer get serializer => + _$gcomparisonFieldsDataFriendsConnectionSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GcomparisonFieldsData_friendsConnection.serializer, + this, + ) as Map); + + static GcomparisonFieldsData_friendsConnection? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GcomparisonFieldsData_friendsConnection.serializer, + json, + ); +} + +abstract class GcomparisonFieldsData_friendsConnection_edges + implements + Built, + GcomparisonFields_friendsConnection_edges { + GcomparisonFieldsData_friendsConnection_edges._(); + + factory GcomparisonFieldsData_friendsConnection_edges( + [Function(GcomparisonFieldsData_friendsConnection_edgesBuilder b) + updates]) = _$GcomparisonFieldsData_friendsConnection_edges; + + static void _initializeBuilder( + GcomparisonFieldsData_friendsConnection_edgesBuilder b) => + b..G__typename = 'FriendsEdge'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + GcomparisonFieldsData_friendsConnection_edges_node? get node; + static Serializer + get serializer => _$gcomparisonFieldsDataFriendsConnectionEdgesSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GcomparisonFieldsData_friendsConnection_edges.serializer, + this, + ) as Map); + + static GcomparisonFieldsData_friendsConnection_edges? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GcomparisonFieldsData_friendsConnection_edges.serializer, + json, + ); +} + +abstract class GcomparisonFieldsData_friendsConnection_edges_node + implements + Built, + GcomparisonFields_friendsConnection_edges_node, + GheroData { + GcomparisonFieldsData_friendsConnection_edges_node._(); + + factory GcomparisonFieldsData_friendsConnection_edges_node( + [Function(GcomparisonFieldsData_friendsConnection_edges_nodeBuilder b) + updates]) = _$GcomparisonFieldsData_friendsConnection_edges_node; + + static void _initializeBuilder( + GcomparisonFieldsData_friendsConnection_edges_nodeBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get name; + static Serializer + get serializer => + _$gcomparisonFieldsDataFriendsConnectionEdgesNodeSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GcomparisonFieldsData_friendsConnection_edges_node.serializer, + this, + ) as Map); + + static GcomparisonFieldsData_friendsConnection_edges_node? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GcomparisonFieldsData_friendsConnection_edges_node.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.data.gql.g.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.data.gql.g.dart new file mode 100644 index 00000000..b5005f79 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.data.gql.g.dart @@ -0,0 +1,1992 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'hero_with_fragments.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gHeroWithFragmentsDataSerializer = + new _$GHeroWithFragmentsDataSerializer(); +Serializer _$gHeroWithFragmentsDataHeroSerializer = + new _$GHeroWithFragmentsData_heroSerializer(); +Serializer + _$gHeroWithFragmentsDataHeroFriendsConnectionSerializer = + new _$GHeroWithFragmentsData_hero_friendsConnectionSerializer(); +Serializer + _$gHeroWithFragmentsDataHeroFriendsConnectionEdgesSerializer = + new _$GHeroWithFragmentsData_hero_friendsConnection_edgesSerializer(); +Serializer + _$gHeroWithFragmentsDataHeroFriendsConnectionEdgesNodeSerializer = + new _$GHeroWithFragmentsData_hero_friendsConnection_edges_nodeSerializer(); +Serializer _$gheroDataDataSerializer = + new _$GheroDataDataSerializer(); +Serializer _$gcomparisonFieldsDataSerializer = + new _$GcomparisonFieldsDataSerializer(); +Serializer + _$gcomparisonFieldsDataFriendsConnectionSerializer = + new _$GcomparisonFieldsData_friendsConnectionSerializer(); +Serializer + _$gcomparisonFieldsDataFriendsConnectionEdgesSerializer = + new _$GcomparisonFieldsData_friendsConnection_edgesSerializer(); +Serializer + _$gcomparisonFieldsDataFriendsConnectionEdgesNodeSerializer = + new _$GcomparisonFieldsData_friendsConnection_edges_nodeSerializer(); + +class _$GHeroWithFragmentsDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroWithFragmentsData, + _$GHeroWithFragmentsData + ]; + @override + final String wireName = 'GHeroWithFragmentsData'; + + @override + Iterable serialize( + Serializers serializers, GHeroWithFragmentsData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.hero; + if (value != null) { + result + ..add('hero') + ..add(serializers.serialize(value, + specifiedType: const FullType(GHeroWithFragmentsData_hero))); + } + return result; + } + + @override + GHeroWithFragmentsData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroWithFragmentsDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'hero': + result.hero.replace(serializers.deserialize(value, + specifiedType: const FullType(GHeroWithFragmentsData_hero))! + as GHeroWithFragmentsData_hero); + break; + } + } + + return result.build(); + } +} + +class _$GHeroWithFragmentsData_heroSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroWithFragmentsData_hero, + _$GHeroWithFragmentsData_hero + ]; + @override + final String wireName = 'GHeroWithFragmentsData_hero'; + + @override + Iterable serialize( + Serializers serializers, GHeroWithFragmentsData_hero object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + 'friendsConnection', + serializers.serialize(object.friendsConnection, + specifiedType: + const FullType(GHeroWithFragmentsData_hero_friendsConnection)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GHeroWithFragmentsData_hero deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroWithFragmentsData_heroBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'friendsConnection': + result.friendsConnection.replace(serializers.deserialize(value, + specifiedType: const FullType( + GHeroWithFragmentsData_hero_friendsConnection))! + as GHeroWithFragmentsData_hero_friendsConnection); + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GHeroWithFragmentsData_hero_friendsConnectionSerializer + implements + StructuredSerializer { + @override + final Iterable types = const [ + GHeroWithFragmentsData_hero_friendsConnection, + _$GHeroWithFragmentsData_hero_friendsConnection + ]; + @override + final String wireName = 'GHeroWithFragmentsData_hero_friendsConnection'; + + @override + Iterable serialize(Serializers serializers, + GHeroWithFragmentsData_hero_friendsConnection object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.totalCount; + if (value != null) { + result + ..add('totalCount') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.edges; + if (value != null) { + result + ..add('edges') + ..add(serializers.serialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable( + GHeroWithFragmentsData_hero_friendsConnection_edges) + ]))); + } + return result; + } + + @override + GHeroWithFragmentsData_hero_friendsConnection deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroWithFragmentsData_hero_friendsConnectionBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'totalCount': + result.totalCount = serializers.deserialize(value, + specifiedType: const FullType(int)) as int?; + break; + case 'edges': + result.edges.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable( + GHeroWithFragmentsData_hero_friendsConnection_edges) + ]))! as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$GHeroWithFragmentsData_hero_friendsConnection_edgesSerializer + implements + StructuredSerializer< + GHeroWithFragmentsData_hero_friendsConnection_edges> { + @override + final Iterable types = const [ + GHeroWithFragmentsData_hero_friendsConnection_edges, + _$GHeroWithFragmentsData_hero_friendsConnection_edges + ]; + @override + final String wireName = 'GHeroWithFragmentsData_hero_friendsConnection_edges'; + + @override + Iterable serialize(Serializers serializers, + GHeroWithFragmentsData_hero_friendsConnection_edges object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.node; + if (value != null) { + result + ..add('node') + ..add(serializers.serialize(value, + specifiedType: const FullType( + GHeroWithFragmentsData_hero_friendsConnection_edges_node))); + } + return result; + } + + @override + GHeroWithFragmentsData_hero_friendsConnection_edges deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = + new GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'node': + result.node.replace(serializers.deserialize(value, + specifiedType: const FullType( + GHeroWithFragmentsData_hero_friendsConnection_edges_node))! + as GHeroWithFragmentsData_hero_friendsConnection_edges_node); + break; + } + } + + return result.build(); + } +} + +class _$GHeroWithFragmentsData_hero_friendsConnection_edges_nodeSerializer + implements + StructuredSerializer< + GHeroWithFragmentsData_hero_friendsConnection_edges_node> { + @override + final Iterable types = const [ + GHeroWithFragmentsData_hero_friendsConnection_edges_node, + _$GHeroWithFragmentsData_hero_friendsConnection_edges_node + ]; + @override + final String wireName = + 'GHeroWithFragmentsData_hero_friendsConnection_edges_node'; + + @override + Iterable serialize(Serializers serializers, + GHeroWithFragmentsData_hero_friendsConnection_edges_node object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GHeroWithFragmentsData_hero_friendsConnection_edges_node deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = + new GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GheroDataDataSerializer implements StructuredSerializer { + @override + final Iterable types = const [GheroDataData, _$GheroDataData]; + @override + final String wireName = 'GheroDataData'; + + @override + Iterable serialize(Serializers serializers, GheroDataData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GheroDataData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GheroDataDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GcomparisonFieldsDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GcomparisonFieldsData, + _$GcomparisonFieldsData + ]; + @override + final String wireName = 'GcomparisonFieldsData'; + + @override + Iterable serialize( + Serializers serializers, GcomparisonFieldsData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + 'friendsConnection', + serializers.serialize(object.friendsConnection, + specifiedType: + const FullType(GcomparisonFieldsData_friendsConnection)), + ]; + + return result; + } + + @override + GcomparisonFieldsData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GcomparisonFieldsDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'friendsConnection': + result.friendsConnection.replace(serializers.deserialize(value, + specifiedType: + const FullType(GcomparisonFieldsData_friendsConnection))! + as GcomparisonFieldsData_friendsConnection); + break; + } + } + + return result.build(); + } +} + +class _$GcomparisonFieldsData_friendsConnectionSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GcomparisonFieldsData_friendsConnection, + _$GcomparisonFieldsData_friendsConnection + ]; + @override + final String wireName = 'GcomparisonFieldsData_friendsConnection'; + + @override + Iterable serialize( + Serializers serializers, GcomparisonFieldsData_friendsConnection object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.totalCount; + if (value != null) { + result + ..add('totalCount') + ..add(serializers.serialize(value, specifiedType: const FullType(int))); + } + value = object.edges; + if (value != null) { + result + ..add('edges') + ..add(serializers.serialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable( + GcomparisonFieldsData_friendsConnection_edges) + ]))); + } + return result; + } + + @override + GcomparisonFieldsData_friendsConnection deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GcomparisonFieldsData_friendsConnectionBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'totalCount': + result.totalCount = serializers.deserialize(value, + specifiedType: const FullType(int)) as int?; + break; + case 'edges': + result.edges.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable( + GcomparisonFieldsData_friendsConnection_edges) + ]))! as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$GcomparisonFieldsData_friendsConnection_edgesSerializer + implements + StructuredSerializer { + @override + final Iterable types = const [ + GcomparisonFieldsData_friendsConnection_edges, + _$GcomparisonFieldsData_friendsConnection_edges + ]; + @override + final String wireName = 'GcomparisonFieldsData_friendsConnection_edges'; + + @override + Iterable serialize(Serializers serializers, + GcomparisonFieldsData_friendsConnection_edges object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.node; + if (value != null) { + result + ..add('node') + ..add(serializers.serialize(value, + specifiedType: const FullType( + GcomparisonFieldsData_friendsConnection_edges_node))); + } + return result; + } + + @override + GcomparisonFieldsData_friendsConnection_edges deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GcomparisonFieldsData_friendsConnection_edgesBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'node': + result.node.replace(serializers.deserialize(value, + specifiedType: const FullType( + GcomparisonFieldsData_friendsConnection_edges_node))! + as GcomparisonFieldsData_friendsConnection_edges_node); + break; + } + } + + return result.build(); + } +} + +class _$GcomparisonFieldsData_friendsConnection_edges_nodeSerializer + implements + StructuredSerializer< + GcomparisonFieldsData_friendsConnection_edges_node> { + @override + final Iterable types = const [ + GcomparisonFieldsData_friendsConnection_edges_node, + _$GcomparisonFieldsData_friendsConnection_edges_node + ]; + @override + final String wireName = 'GcomparisonFieldsData_friendsConnection_edges_node'; + + @override + Iterable serialize(Serializers serializers, + GcomparisonFieldsData_friendsConnection_edges_node object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GcomparisonFieldsData_friendsConnection_edges_node deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = + new GcomparisonFieldsData_friendsConnection_edges_nodeBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GHeroWithFragmentsData extends GHeroWithFragmentsData { + @override + final String G__typename; + @override + final GHeroWithFragmentsData_hero? hero; + + factory _$GHeroWithFragmentsData( + [void Function(GHeroWithFragmentsDataBuilder)? updates]) => + (new GHeroWithFragmentsDataBuilder()..update(updates))._build(); + + _$GHeroWithFragmentsData._({required this.G__typename, this.hero}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroWithFragmentsData', 'G__typename'); + } + + @override + GHeroWithFragmentsData rebuild( + void Function(GHeroWithFragmentsDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWithFragmentsDataBuilder toBuilder() => + new GHeroWithFragmentsDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWithFragmentsData && + G__typename == other.G__typename && + hero == other.hero; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, hero.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroWithFragmentsData') + ..add('G__typename', G__typename) + ..add('hero', hero)) + .toString(); + } +} + +class GHeroWithFragmentsDataBuilder + implements Builder { + _$GHeroWithFragmentsData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GHeroWithFragmentsData_heroBuilder? _hero; + GHeroWithFragmentsData_heroBuilder get hero => + _$this._hero ??= new GHeroWithFragmentsData_heroBuilder(); + set hero(GHeroWithFragmentsData_heroBuilder? hero) => _$this._hero = hero; + + GHeroWithFragmentsDataBuilder() { + GHeroWithFragmentsData._initializeBuilder(this); + } + + GHeroWithFragmentsDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _hero = $v.hero?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GHeroWithFragmentsData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWithFragmentsData; + } + + @override + void update(void Function(GHeroWithFragmentsDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroWithFragmentsData build() => _build(); + + _$GHeroWithFragmentsData _build() { + _$GHeroWithFragmentsData _$result; + try { + _$result = _$v ?? + new _$GHeroWithFragmentsData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroWithFragmentsData', 'G__typename'), + hero: _hero?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'hero'; + _hero?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroWithFragmentsData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GHeroWithFragmentsData_hero extends GHeroWithFragmentsData_hero { + @override + final String G__typename; + @override + final String id; + @override + final GHeroWithFragmentsData_hero_friendsConnection friendsConnection; + @override + final String name; + + factory _$GHeroWithFragmentsData_hero( + [void Function(GHeroWithFragmentsData_heroBuilder)? updates]) => + (new GHeroWithFragmentsData_heroBuilder()..update(updates))._build(); + + _$GHeroWithFragmentsData_hero._( + {required this.G__typename, + required this.id, + required this.friendsConnection, + required this.name}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroWithFragmentsData_hero', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + id, r'GHeroWithFragmentsData_hero', 'id'); + BuiltValueNullFieldError.checkNotNull( + friendsConnection, r'GHeroWithFragmentsData_hero', 'friendsConnection'); + BuiltValueNullFieldError.checkNotNull( + name, r'GHeroWithFragmentsData_hero', 'name'); + } + + @override + GHeroWithFragmentsData_hero rebuild( + void Function(GHeroWithFragmentsData_heroBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWithFragmentsData_heroBuilder toBuilder() => + new GHeroWithFragmentsData_heroBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWithFragmentsData_hero && + G__typename == other.G__typename && + id == other.id && + friendsConnection == other.friendsConnection && + name == other.name; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, friendsConnection.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroWithFragmentsData_hero') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('friendsConnection', friendsConnection) + ..add('name', name)) + .toString(); + } +} + +class GHeroWithFragmentsData_heroBuilder + implements + Builder { + _$GHeroWithFragmentsData_hero? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + GHeroWithFragmentsData_hero_friendsConnectionBuilder? _friendsConnection; + GHeroWithFragmentsData_hero_friendsConnectionBuilder get friendsConnection => + _$this._friendsConnection ??= + new GHeroWithFragmentsData_hero_friendsConnectionBuilder(); + set friendsConnection( + GHeroWithFragmentsData_hero_friendsConnectionBuilder? + friendsConnection) => + _$this._friendsConnection = friendsConnection; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + GHeroWithFragmentsData_heroBuilder() { + GHeroWithFragmentsData_hero._initializeBuilder(this); + } + + GHeroWithFragmentsData_heroBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _friendsConnection = $v.friendsConnection.toBuilder(); + _name = $v.name; + _$v = null; + } + return this; + } + + @override + void replace(GHeroWithFragmentsData_hero other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWithFragmentsData_hero; + } + + @override + void update(void Function(GHeroWithFragmentsData_heroBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroWithFragmentsData_hero build() => _build(); + + _$GHeroWithFragmentsData_hero _build() { + _$GHeroWithFragmentsData_hero _$result; + try { + _$result = _$v ?? + new _$GHeroWithFragmentsData_hero._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroWithFragmentsData_hero', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GHeroWithFragmentsData_hero', 'id'), + friendsConnection: friendsConnection.build(), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GHeroWithFragmentsData_hero', 'name')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'friendsConnection'; + friendsConnection.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroWithFragmentsData_hero', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GHeroWithFragmentsData_hero_friendsConnection + extends GHeroWithFragmentsData_hero_friendsConnection { + @override + final String G__typename; + @override + final int? totalCount; + @override + final BuiltList? edges; + + factory _$GHeroWithFragmentsData_hero_friendsConnection( + [void Function(GHeroWithFragmentsData_hero_friendsConnectionBuilder)? + updates]) => + (new GHeroWithFragmentsData_hero_friendsConnectionBuilder() + ..update(updates)) + ._build(); + + _$GHeroWithFragmentsData_hero_friendsConnection._( + {required this.G__typename, this.totalCount, this.edges}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GHeroWithFragmentsData_hero_friendsConnection', 'G__typename'); + } + + @override + GHeroWithFragmentsData_hero_friendsConnection rebuild( + void Function(GHeroWithFragmentsData_hero_friendsConnectionBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWithFragmentsData_hero_friendsConnectionBuilder toBuilder() => + new GHeroWithFragmentsData_hero_friendsConnectionBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWithFragmentsData_hero_friendsConnection && + G__typename == other.G__typename && + totalCount == other.totalCount && + edges == other.edges; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, totalCount.hashCode); + _$hash = $jc(_$hash, edges.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GHeroWithFragmentsData_hero_friendsConnection') + ..add('G__typename', G__typename) + ..add('totalCount', totalCount) + ..add('edges', edges)) + .toString(); + } +} + +class GHeroWithFragmentsData_hero_friendsConnectionBuilder + implements + Builder { + _$GHeroWithFragmentsData_hero_friendsConnection? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + int? _totalCount; + int? get totalCount => _$this._totalCount; + set totalCount(int? totalCount) => _$this._totalCount = totalCount; + + ListBuilder? _edges; + ListBuilder< + GHeroWithFragmentsData_hero_friendsConnection_edges?> get edges => _$this + ._edges ??= + new ListBuilder(); + set edges( + ListBuilder? + edges) => + _$this._edges = edges; + + GHeroWithFragmentsData_hero_friendsConnectionBuilder() { + GHeroWithFragmentsData_hero_friendsConnection._initializeBuilder(this); + } + + GHeroWithFragmentsData_hero_friendsConnectionBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _totalCount = $v.totalCount; + _edges = $v.edges?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GHeroWithFragmentsData_hero_friendsConnection other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWithFragmentsData_hero_friendsConnection; + } + + @override + void update( + void Function(GHeroWithFragmentsData_hero_friendsConnectionBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GHeroWithFragmentsData_hero_friendsConnection build() => _build(); + + _$GHeroWithFragmentsData_hero_friendsConnection _build() { + _$GHeroWithFragmentsData_hero_friendsConnection _$result; + try { + _$result = _$v ?? + new _$GHeroWithFragmentsData_hero_friendsConnection._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, + r'GHeroWithFragmentsData_hero_friendsConnection', + 'G__typename'), + totalCount: totalCount, + edges: _edges?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'edges'; + _edges?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroWithFragmentsData_hero_friendsConnection', + _$failedField, + e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GHeroWithFragmentsData_hero_friendsConnection_edges + extends GHeroWithFragmentsData_hero_friendsConnection_edges { + @override + final String G__typename; + @override + final GHeroWithFragmentsData_hero_friendsConnection_edges_node? node; + + factory _$GHeroWithFragmentsData_hero_friendsConnection_edges( + [void Function( + GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder)? + updates]) => + (new GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder() + ..update(updates)) + ._build(); + + _$GHeroWithFragmentsData_hero_friendsConnection_edges._( + {required this.G__typename, this.node}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GHeroWithFragmentsData_hero_friendsConnection_edges', 'G__typename'); + } + + @override + GHeroWithFragmentsData_hero_friendsConnection_edges rebuild( + void Function( + GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder toBuilder() => + new GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder() + ..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWithFragmentsData_hero_friendsConnection_edges && + G__typename == other.G__typename && + node == other.node; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, node.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GHeroWithFragmentsData_hero_friendsConnection_edges') + ..add('G__typename', G__typename) + ..add('node', node)) + .toString(); + } +} + +class GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder + implements + Builder { + _$GHeroWithFragmentsData_hero_friendsConnection_edges? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder? _node; + GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder get node => + _$this._node ??= + new GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder(); + set node( + GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder? + node) => + _$this._node = node; + + GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder() { + GHeroWithFragmentsData_hero_friendsConnection_edges._initializeBuilder( + this); + } + + GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _node = $v.node?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GHeroWithFragmentsData_hero_friendsConnection_edges other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWithFragmentsData_hero_friendsConnection_edges; + } + + @override + void update( + void Function(GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GHeroWithFragmentsData_hero_friendsConnection_edges build() => _build(); + + _$GHeroWithFragmentsData_hero_friendsConnection_edges _build() { + _$GHeroWithFragmentsData_hero_friendsConnection_edges _$result; + try { + _$result = _$v ?? + new _$GHeroWithFragmentsData_hero_friendsConnection_edges._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, + r'GHeroWithFragmentsData_hero_friendsConnection_edges', + 'G__typename'), + node: _node?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'node'; + _node?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroWithFragmentsData_hero_friendsConnection_edges', + _$failedField, + e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GHeroWithFragmentsData_hero_friendsConnection_edges_node + extends GHeroWithFragmentsData_hero_friendsConnection_edges_node { + @override + final String G__typename; + @override + final String name; + + factory _$GHeroWithFragmentsData_hero_friendsConnection_edges_node( + [void Function( + GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder)? + updates]) => + (new GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder() + ..update(updates)) + ._build(); + + _$GHeroWithFragmentsData_hero_friendsConnection_edges_node._( + {required this.G__typename, required this.name}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, + r'GHeroWithFragmentsData_hero_friendsConnection_edges_node', + 'G__typename'); + BuiltValueNullFieldError.checkNotNull(name, + r'GHeroWithFragmentsData_hero_friendsConnection_edges_node', 'name'); + } + + @override + GHeroWithFragmentsData_hero_friendsConnection_edges_node rebuild( + void Function( + GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder toBuilder() => + new GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder() + ..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWithFragmentsData_hero_friendsConnection_edges_node && + G__typename == other.G__typename && + name == other.name; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GHeroWithFragmentsData_hero_friendsConnection_edges_node') + ..add('G__typename', G__typename) + ..add('name', name)) + .toString(); + } +} + +class GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder + implements + Builder { + _$GHeroWithFragmentsData_hero_friendsConnection_edges_node? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder() { + GHeroWithFragmentsData_hero_friendsConnection_edges_node._initializeBuilder( + this); + } + + GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _name = $v.name; + _$v = null; + } + return this; + } + + @override + void replace(GHeroWithFragmentsData_hero_friendsConnection_edges_node other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWithFragmentsData_hero_friendsConnection_edges_node; + } + + @override + void update( + void Function( + GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GHeroWithFragmentsData_hero_friendsConnection_edges_node build() => _build(); + + _$GHeroWithFragmentsData_hero_friendsConnection_edges_node _build() { + final _$result = _$v ?? + new _$GHeroWithFragmentsData_hero_friendsConnection_edges_node._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, + r'GHeroWithFragmentsData_hero_friendsConnection_edges_node', + 'G__typename'), + name: BuiltValueNullFieldError.checkNotNull( + name, + r'GHeroWithFragmentsData_hero_friendsConnection_edges_node', + 'name')); + replace(_$result); + return _$result; + } +} + +class _$GheroDataData extends GheroDataData { + @override + final String G__typename; + @override + final String name; + + factory _$GheroDataData([void Function(GheroDataDataBuilder)? updates]) => + (new GheroDataDataBuilder()..update(updates))._build(); + + _$GheroDataData._({required this.G__typename, required this.name}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GheroDataData', 'G__typename'); + BuiltValueNullFieldError.checkNotNull(name, r'GheroDataData', 'name'); + } + + @override + GheroDataData rebuild(void Function(GheroDataDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GheroDataDataBuilder toBuilder() => new GheroDataDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GheroDataData && + G__typename == other.G__typename && + name == other.name; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GheroDataData') + ..add('G__typename', G__typename) + ..add('name', name)) + .toString(); + } +} + +class GheroDataDataBuilder + implements Builder { + _$GheroDataData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + GheroDataDataBuilder() { + GheroDataData._initializeBuilder(this); + } + + GheroDataDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _name = $v.name; + _$v = null; + } + return this; + } + + @override + void replace(GheroDataData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GheroDataData; + } + + @override + void update(void Function(GheroDataDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GheroDataData build() => _build(); + + _$GheroDataData _build() { + final _$result = _$v ?? + new _$GheroDataData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GheroDataData', 'G__typename'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GheroDataData', 'name')); + replace(_$result); + return _$result; + } +} + +class _$GcomparisonFieldsData extends GcomparisonFieldsData { + @override + final String G__typename; + @override + final String id; + @override + final String name; + @override + final GcomparisonFieldsData_friendsConnection friendsConnection; + + factory _$GcomparisonFieldsData( + [void Function(GcomparisonFieldsDataBuilder)? updates]) => + (new GcomparisonFieldsDataBuilder()..update(updates))._build(); + + _$GcomparisonFieldsData._( + {required this.G__typename, + required this.id, + required this.name, + required this.friendsConnection}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GcomparisonFieldsData', 'G__typename'); + BuiltValueNullFieldError.checkNotNull(id, r'GcomparisonFieldsData', 'id'); + BuiltValueNullFieldError.checkNotNull( + name, r'GcomparisonFieldsData', 'name'); + BuiltValueNullFieldError.checkNotNull( + friendsConnection, r'GcomparisonFieldsData', 'friendsConnection'); + } + + @override + GcomparisonFieldsData rebuild( + void Function(GcomparisonFieldsDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GcomparisonFieldsDataBuilder toBuilder() => + new GcomparisonFieldsDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GcomparisonFieldsData && + G__typename == other.G__typename && + id == other.id && + name == other.name && + friendsConnection == other.friendsConnection; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, friendsConnection.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GcomparisonFieldsData') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('name', name) + ..add('friendsConnection', friendsConnection)) + .toString(); + } +} + +class GcomparisonFieldsDataBuilder + implements Builder { + _$GcomparisonFieldsData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + GcomparisonFieldsData_friendsConnectionBuilder? _friendsConnection; + GcomparisonFieldsData_friendsConnectionBuilder get friendsConnection => + _$this._friendsConnection ??= + new GcomparisonFieldsData_friendsConnectionBuilder(); + set friendsConnection( + GcomparisonFieldsData_friendsConnectionBuilder? friendsConnection) => + _$this._friendsConnection = friendsConnection; + + GcomparisonFieldsDataBuilder() { + GcomparisonFieldsData._initializeBuilder(this); + } + + GcomparisonFieldsDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _name = $v.name; + _friendsConnection = $v.friendsConnection.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GcomparisonFieldsData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GcomparisonFieldsData; + } + + @override + void update(void Function(GcomparisonFieldsDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GcomparisonFieldsData build() => _build(); + + _$GcomparisonFieldsData _build() { + _$GcomparisonFieldsData _$result; + try { + _$result = _$v ?? + new _$GcomparisonFieldsData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GcomparisonFieldsData', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GcomparisonFieldsData', 'id'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GcomparisonFieldsData', 'name'), + friendsConnection: friendsConnection.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'friendsConnection'; + friendsConnection.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GcomparisonFieldsData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GcomparisonFieldsData_friendsConnection + extends GcomparisonFieldsData_friendsConnection { + @override + final String G__typename; + @override + final int? totalCount; + @override + final BuiltList? edges; + + factory _$GcomparisonFieldsData_friendsConnection( + [void Function(GcomparisonFieldsData_friendsConnectionBuilder)? + updates]) => + (new GcomparisonFieldsData_friendsConnectionBuilder()..update(updates)) + ._build(); + + _$GcomparisonFieldsData_friendsConnection._( + {required this.G__typename, this.totalCount, this.edges}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GcomparisonFieldsData_friendsConnection', 'G__typename'); + } + + @override + GcomparisonFieldsData_friendsConnection rebuild( + void Function(GcomparisonFieldsData_friendsConnectionBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GcomparisonFieldsData_friendsConnectionBuilder toBuilder() => + new GcomparisonFieldsData_friendsConnectionBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GcomparisonFieldsData_friendsConnection && + G__typename == other.G__typename && + totalCount == other.totalCount && + edges == other.edges; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, totalCount.hashCode); + _$hash = $jc(_$hash, edges.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GcomparisonFieldsData_friendsConnection') + ..add('G__typename', G__typename) + ..add('totalCount', totalCount) + ..add('edges', edges)) + .toString(); + } +} + +class GcomparisonFieldsData_friendsConnectionBuilder + implements + Builder { + _$GcomparisonFieldsData_friendsConnection? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + int? _totalCount; + int? get totalCount => _$this._totalCount; + set totalCount(int? totalCount) => _$this._totalCount = totalCount; + + ListBuilder? _edges; + ListBuilder get edges => + _$this._edges ??= + new ListBuilder(); + set edges( + ListBuilder? edges) => + _$this._edges = edges; + + GcomparisonFieldsData_friendsConnectionBuilder() { + GcomparisonFieldsData_friendsConnection._initializeBuilder(this); + } + + GcomparisonFieldsData_friendsConnectionBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _totalCount = $v.totalCount; + _edges = $v.edges?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GcomparisonFieldsData_friendsConnection other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GcomparisonFieldsData_friendsConnection; + } + + @override + void update( + void Function(GcomparisonFieldsData_friendsConnectionBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GcomparisonFieldsData_friendsConnection build() => _build(); + + _$GcomparisonFieldsData_friendsConnection _build() { + _$GcomparisonFieldsData_friendsConnection _$result; + try { + _$result = _$v ?? + new _$GcomparisonFieldsData_friendsConnection._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GcomparisonFieldsData_friendsConnection', 'G__typename'), + totalCount: totalCount, + edges: _edges?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'edges'; + _edges?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GcomparisonFieldsData_friendsConnection', + _$failedField, + e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GcomparisonFieldsData_friendsConnection_edges + extends GcomparisonFieldsData_friendsConnection_edges { + @override + final String G__typename; + @override + final GcomparisonFieldsData_friendsConnection_edges_node? node; + + factory _$GcomparisonFieldsData_friendsConnection_edges( + [void Function(GcomparisonFieldsData_friendsConnection_edgesBuilder)? + updates]) => + (new GcomparisonFieldsData_friendsConnection_edgesBuilder() + ..update(updates)) + ._build(); + + _$GcomparisonFieldsData_friendsConnection_edges._( + {required this.G__typename, this.node}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GcomparisonFieldsData_friendsConnection_edges', 'G__typename'); + } + + @override + GcomparisonFieldsData_friendsConnection_edges rebuild( + void Function(GcomparisonFieldsData_friendsConnection_edgesBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GcomparisonFieldsData_friendsConnection_edgesBuilder toBuilder() => + new GcomparisonFieldsData_friendsConnection_edgesBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GcomparisonFieldsData_friendsConnection_edges && + G__typename == other.G__typename && + node == other.node; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, node.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GcomparisonFieldsData_friendsConnection_edges') + ..add('G__typename', G__typename) + ..add('node', node)) + .toString(); + } +} + +class GcomparisonFieldsData_friendsConnection_edgesBuilder + implements + Builder { + _$GcomparisonFieldsData_friendsConnection_edges? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GcomparisonFieldsData_friendsConnection_edges_nodeBuilder? _node; + GcomparisonFieldsData_friendsConnection_edges_nodeBuilder get node => + _$this._node ??= + new GcomparisonFieldsData_friendsConnection_edges_nodeBuilder(); + set node(GcomparisonFieldsData_friendsConnection_edges_nodeBuilder? node) => + _$this._node = node; + + GcomparisonFieldsData_friendsConnection_edgesBuilder() { + GcomparisonFieldsData_friendsConnection_edges._initializeBuilder(this); + } + + GcomparisonFieldsData_friendsConnection_edgesBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _node = $v.node?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GcomparisonFieldsData_friendsConnection_edges other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GcomparisonFieldsData_friendsConnection_edges; + } + + @override + void update( + void Function(GcomparisonFieldsData_friendsConnection_edgesBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GcomparisonFieldsData_friendsConnection_edges build() => _build(); + + _$GcomparisonFieldsData_friendsConnection_edges _build() { + _$GcomparisonFieldsData_friendsConnection_edges _$result; + try { + _$result = _$v ?? + new _$GcomparisonFieldsData_friendsConnection_edges._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, + r'GcomparisonFieldsData_friendsConnection_edges', + 'G__typename'), + node: _node?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'node'; + _node?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GcomparisonFieldsData_friendsConnection_edges', + _$failedField, + e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GcomparisonFieldsData_friendsConnection_edges_node + extends GcomparisonFieldsData_friendsConnection_edges_node { + @override + final String G__typename; + @override + final String name; + + factory _$GcomparisonFieldsData_friendsConnection_edges_node( + [void Function( + GcomparisonFieldsData_friendsConnection_edges_nodeBuilder)? + updates]) => + (new GcomparisonFieldsData_friendsConnection_edges_nodeBuilder() + ..update(updates)) + ._build(); + + _$GcomparisonFieldsData_friendsConnection_edges_node._( + {required this.G__typename, required this.name}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GcomparisonFieldsData_friendsConnection_edges_node', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + name, r'GcomparisonFieldsData_friendsConnection_edges_node', 'name'); + } + + @override + GcomparisonFieldsData_friendsConnection_edges_node rebuild( + void Function( + GcomparisonFieldsData_friendsConnection_edges_nodeBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GcomparisonFieldsData_friendsConnection_edges_nodeBuilder toBuilder() => + new GcomparisonFieldsData_friendsConnection_edges_nodeBuilder() + ..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GcomparisonFieldsData_friendsConnection_edges_node && + G__typename == other.G__typename && + name == other.name; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GcomparisonFieldsData_friendsConnection_edges_node') + ..add('G__typename', G__typename) + ..add('name', name)) + .toString(); + } +} + +class GcomparisonFieldsData_friendsConnection_edges_nodeBuilder + implements + Builder { + _$GcomparisonFieldsData_friendsConnection_edges_node? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + GcomparisonFieldsData_friendsConnection_edges_nodeBuilder() { + GcomparisonFieldsData_friendsConnection_edges_node._initializeBuilder(this); + } + + GcomparisonFieldsData_friendsConnection_edges_nodeBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _name = $v.name; + _$v = null; + } + return this; + } + + @override + void replace(GcomparisonFieldsData_friendsConnection_edges_node other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GcomparisonFieldsData_friendsConnection_edges_node; + } + + @override + void update( + void Function(GcomparisonFieldsData_friendsConnection_edges_nodeBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GcomparisonFieldsData_friendsConnection_edges_node build() => _build(); + + _$GcomparisonFieldsData_friendsConnection_edges_node _build() { + final _$result = _$v ?? + new _$GcomparisonFieldsData_friendsConnection_edges_node._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, + r'GcomparisonFieldsData_friendsConnection_edges_node', + 'G__typename'), + name: BuiltValueNullFieldError.checkNotNull(name, + r'GcomparisonFieldsData_friendsConnection_edges_node', 'name')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.req.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.req.gql.dart new file mode 100644 index 00000000..beae8325 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.req.gql.dart @@ -0,0 +1,45 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_fragments.ast.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_fragments.var.gql.dart' + as _i3; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'hero_with_fragments.req.gql.g.dart'; + +abstract class GHeroWithFragments + implements Built { + GHeroWithFragments._(); + + factory GHeroWithFragments([Function(GHeroWithFragmentsBuilder b) updates]) = + _$GHeroWithFragments; + + static void _initializeBuilder(GHeroWithFragmentsBuilder b) => b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'HeroWithFragments', + ); + + _i3.GHeroWithFragmentsVars get vars; + _i1.Operation get operation; + static Serializer get serializer => + _$gHeroWithFragmentsSerializer; + + Map toJson() => (_i4.serializers.serializeWith( + GHeroWithFragments.serializer, + this, + ) as Map); + + static GHeroWithFragments? fromJson(Map json) => + _i4.serializers.deserializeWith( + GHeroWithFragments.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.req.gql.g.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.req.gql.g.dart new file mode 100644 index 00000000..075810ea --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.req.gql.g.dart @@ -0,0 +1,180 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'hero_with_fragments.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gHeroWithFragmentsSerializer = + new _$GHeroWithFragmentsSerializer(); + +class _$GHeroWithFragmentsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GHeroWithFragments, _$GHeroWithFragments]; + @override + final String wireName = 'GHeroWithFragments'; + + @override + Iterable serialize( + Serializers serializers, GHeroWithFragments object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: const FullType(_i3.GHeroWithFragmentsVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GHeroWithFragments deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroWithFragmentsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'vars': + result.vars.replace(serializers.deserialize(value, + specifiedType: const FullType(_i3.GHeroWithFragmentsVars))! + as _i3.GHeroWithFragmentsVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GHeroWithFragments extends GHeroWithFragments { + @override + final _i3.GHeroWithFragmentsVars vars; + @override + final _i1.Operation operation; + + factory _$GHeroWithFragments( + [void Function(GHeroWithFragmentsBuilder)? updates]) => + (new GHeroWithFragmentsBuilder()..update(updates))._build(); + + _$GHeroWithFragments._({required this.vars, required this.operation}) + : super._() { + BuiltValueNullFieldError.checkNotNull(vars, r'GHeroWithFragments', 'vars'); + BuiltValueNullFieldError.checkNotNull( + operation, r'GHeroWithFragments', 'operation'); + } + + @override + GHeroWithFragments rebuild( + void Function(GHeroWithFragmentsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWithFragmentsBuilder toBuilder() => + new GHeroWithFragmentsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWithFragments && + vars == other.vars && + operation == other.operation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroWithFragments') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GHeroWithFragmentsBuilder + implements Builder { + _$GHeroWithFragments? _$v; + + _i3.GHeroWithFragmentsVarsBuilder? _vars; + _i3.GHeroWithFragmentsVarsBuilder get vars => + _$this._vars ??= new _i3.GHeroWithFragmentsVarsBuilder(); + set vars(_i3.GHeroWithFragmentsVarsBuilder? vars) => _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GHeroWithFragmentsBuilder() { + GHeroWithFragments._initializeBuilder(this); + } + + GHeroWithFragmentsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GHeroWithFragments other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWithFragments; + } + + @override + void update(void Function(GHeroWithFragmentsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroWithFragments build() => _build(); + + _$GHeroWithFragments _build() { + _$GHeroWithFragments _$result; + try { + _$result = _$v ?? + new _$GHeroWithFragments._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull( + operation, r'GHeroWithFragments', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroWithFragments', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.dart new file mode 100644 index 00000000..d354e80f --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.dart @@ -0,0 +1,199 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i2; +import 'package:gql_exec/value.dart' as _i1; + +part 'hero_with_fragments.var.gql.g.dart'; + +abstract class GHeroWithFragmentsVars + implements Built { + GHeroWithFragmentsVars._(); + + factory GHeroWithFragmentsVars( + [Function(GHeroWithFragmentsVarsBuilder b) updates]) = + _$GHeroWithFragmentsVars; + + static void _initializeBuilder(GHeroWithFragmentsVarsBuilder b) => + b..first = const _i1.AbsentValue(); + + _i1.Value? get first; + Map toJson() => (_i2.serializers.serializeWith( + GHeroWithFragmentsVars.serializer, + this, + ) as Map); + + static GHeroWithFragmentsVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GHeroWithFragmentsVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GHeroWithFragmentsVarsSerializer(); +} + +abstract class GheroDataVars + implements Built { + GheroDataVars._(); + + factory GheroDataVars([Function(GheroDataVarsBuilder b) updates]) = + _$GheroDataVars; + + Map toJson() => (_i2.serializers.serializeWith( + GheroDataVars.serializer, + this, + ) as Map); + + static GheroDataVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GheroDataVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => GheroDataVarsSerializer(); +} + +abstract class GcomparisonFieldsVars + implements Built { + GcomparisonFieldsVars._(); + + factory GcomparisonFieldsVars( + [Function(GcomparisonFieldsVarsBuilder b) updates]) = + _$GcomparisonFieldsVars; + + int? get first; + Map toJson() => (_i2.serializers.serializeWith( + GcomparisonFieldsVars.serializer, + this, + ) as Map); + + static GcomparisonFieldsVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GcomparisonFieldsVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GcomparisonFieldsVarsSerializer(); +} + +class GHeroWithFragmentsVarsSerializer + extends StructuredSerializer { + final String wireName = 'GHeroWithFragmentsVars'; + + final Iterable types = const [ + GHeroWithFragmentsVars, + _$GHeroWithFragmentsVars + ]; + + Iterable serialize( + Serializers serializers, + GHeroWithFragmentsVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + final _$firstvalue = object.first; + if (_$firstvalue case _i1.PresentValue(value: final _$value)) { + result.add('first'); + result.add( + serializers.serialize(_$value, specifiedType: const FullType(int))); + } + return result; + } + + GHeroWithFragmentsVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GHeroWithFragmentsVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'first': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + builder.first = _i1.PresentValue(fieldValue); + break; + } + } + return builder.build(); + } +} + +class GheroDataVarsSerializer extends StructuredSerializer { + final String wireName = 'GheroDataVars'; + + final Iterable types = const [GheroDataVars, _$GheroDataVars]; + + Iterable serialize( + Serializers serializers, + GheroDataVars object, { + FullType specifiedType = FullType.unspecified, + }) { + return const []; + } + + GheroDataVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + return GheroDataVars(); + } +} + +class GcomparisonFieldsVarsSerializer + extends StructuredSerializer { + final String wireName = 'GcomparisonFieldsVars'; + + final Iterable types = const [ + GcomparisonFieldsVars, + _$GcomparisonFieldsVars + ]; + + Iterable serialize( + Serializers serializers, + GcomparisonFieldsVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('first'); + result.add(serializers.serialize(object.first, + specifiedType: const FullType(int))); + return result; + } + + GcomparisonFieldsVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GcomparisonFieldsVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'first': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + builder.first = fieldValue; + break; + } + } + return builder.build(); + } +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.g.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.g.dart new file mode 100644 index 00000000..d5f4e880 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.g.dart @@ -0,0 +1,230 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'hero_with_fragments.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$GHeroWithFragmentsVars extends GHeroWithFragmentsVars { + @override + final _i1.Value? first; + + factory _$GHeroWithFragmentsVars( + [void Function(GHeroWithFragmentsVarsBuilder)? updates]) => + (new GHeroWithFragmentsVarsBuilder()..update(updates))._build(); + + _$GHeroWithFragmentsVars._({this.first}) : super._(); + + @override + GHeroWithFragmentsVars rebuild( + void Function(GHeroWithFragmentsVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWithFragmentsVarsBuilder toBuilder() => + new GHeroWithFragmentsVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWithFragmentsVars && first == other.first; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, first.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroWithFragmentsVars') + ..add('first', first)) + .toString(); + } +} + +class GHeroWithFragmentsVarsBuilder + implements Builder { + _$GHeroWithFragmentsVars? _$v; + + _i1.Value? _first; + _i1.Value? get first => _$this._first; + set first(_i1.Value? first) => _$this._first = first; + + GHeroWithFragmentsVarsBuilder() { + GHeroWithFragmentsVars._initializeBuilder(this); + } + + GHeroWithFragmentsVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _first = $v.first; + _$v = null; + } + return this; + } + + @override + void replace(GHeroWithFragmentsVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWithFragmentsVars; + } + + @override + void update(void Function(GHeroWithFragmentsVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroWithFragmentsVars build() => _build(); + + _$GHeroWithFragmentsVars _build() { + final _$result = _$v ?? new _$GHeroWithFragmentsVars._(first: first); + replace(_$result); + return _$result; + } +} + +class _$GheroDataVars extends GheroDataVars { + factory _$GheroDataVars([void Function(GheroDataVarsBuilder)? updates]) => + (new GheroDataVarsBuilder()..update(updates))._build(); + + _$GheroDataVars._() : super._(); + + @override + GheroDataVars rebuild(void Function(GheroDataVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GheroDataVarsBuilder toBuilder() => new GheroDataVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GheroDataVars; + } + + @override + int get hashCode { + return 172200517; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GheroDataVars').toString(); + } +} + +class GheroDataVarsBuilder + implements Builder { + _$GheroDataVars? _$v; + + GheroDataVarsBuilder(); + + @override + void replace(GheroDataVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GheroDataVars; + } + + @override + void update(void Function(GheroDataVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GheroDataVars build() => _build(); + + _$GheroDataVars _build() { + final _$result = _$v ?? new _$GheroDataVars._(); + replace(_$result); + return _$result; + } +} + +class _$GcomparisonFieldsVars extends GcomparisonFieldsVars { + @override + final int? first; + + factory _$GcomparisonFieldsVars( + [void Function(GcomparisonFieldsVarsBuilder)? updates]) => + (new GcomparisonFieldsVarsBuilder()..update(updates))._build(); + + _$GcomparisonFieldsVars._({this.first}) : super._(); + + @override + GcomparisonFieldsVars rebuild( + void Function(GcomparisonFieldsVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GcomparisonFieldsVarsBuilder toBuilder() => + new GcomparisonFieldsVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GcomparisonFieldsVars && first == other.first; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, first.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GcomparisonFieldsVars') + ..add('first', first)) + .toString(); + } +} + +class GcomparisonFieldsVarsBuilder + implements Builder { + _$GcomparisonFieldsVars? _$v; + + int? _first; + int? get first => _$this._first; + set first(int? first) => _$this._first = first; + + GcomparisonFieldsVarsBuilder(); + + GcomparisonFieldsVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _first = $v.first; + _$v = null; + } + return this; + } + + @override + void replace(GcomparisonFieldsVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GcomparisonFieldsVars; + } + + @override + void update(void Function(GcomparisonFieldsVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GcomparisonFieldsVars build() => _build(); + + _$GcomparisonFieldsVars _build() { + final _$result = _$v ?? new _$GcomparisonFieldsVars._(first: first); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.ast.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.ast.gql.dart new file mode 100644 index 00000000..0ff9ac58 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.ast.gql.dart @@ -0,0 +1,203 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const HeroWithInterfaceSubTypedFragments = _i1.OperationDefinitionNode( + type: _i1.OperationType.query, + name: _i1.NameNode(value: 'HeroWithInterfaceSubTypedFragments'), + variableDefinitions: [ + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'episode')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Episode'), + isNonNull: true, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'hero'), + alias: null, + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'episode'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'episode')), + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'heroFieldsFragment'), + directives: [], + ) + ]), + ) + ]), +); +const heroFieldsFragment = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'heroFieldsFragment'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.InlineFragmentNode( + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Human'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'humanFieldsFragment'), + directives: [], + ) + ]), + ), + _i1.InlineFragmentNode( + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Droid'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'droidFieldsFragment'), + directives: [], + ) + ]), + ), + ]), +); +const humanFieldsFragment = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'humanFieldsFragment'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Human'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'homePlanet'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'friends'), + alias: null, + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.InlineFragmentNode( + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Droid'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'droidFieldsFragment'), + directives: [], + ), + ]), + ), + _i1.InlineFragmentNode( + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Human'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'homePlanet'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + ]), + ), + ]), +); +const droidFieldsFragment = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'droidFieldsFragment'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Droid'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'primaryFunction'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), +); +const document = _i1.DocumentNode(definitions: [ + HeroWithInterfaceSubTypedFragments, + heroFieldsFragment, + humanFieldsFragment, + droidFieldsFragment, +]); diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.dart new file mode 100644 index 00000000..f31c56fb --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.dart @@ -0,0 +1,946 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; +import 'package:gql_code_builder/src/serializers/inline_fragment_serializer.dart' + as _i2; + +part 'hero_with_interface_subtyped_fragments.data.gql.g.dart'; + +abstract class GHeroWithInterfaceSubTypedFragmentsData + implements + Built { + GHeroWithInterfaceSubTypedFragmentsData._(); + + factory GHeroWithInterfaceSubTypedFragmentsData( + [Function(GHeroWithInterfaceSubTypedFragmentsDataBuilder b) + updates]) = _$GHeroWithInterfaceSubTypedFragmentsData; + + static void _initializeBuilder( + GHeroWithInterfaceSubTypedFragmentsDataBuilder b) => + b..G__typename = 'Query'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + GHeroWithInterfaceSubTypedFragmentsData_hero? get hero; + static Serializer get serializer => + _$gHeroWithInterfaceSubTypedFragmentsDataSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GHeroWithInterfaceSubTypedFragmentsData.serializer, + this, + ) as Map); + + static GHeroWithInterfaceSubTypedFragmentsData? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GHeroWithInterfaceSubTypedFragmentsData.serializer, + json, + ); +} + +abstract class GHeroWithInterfaceSubTypedFragmentsData_hero + implements + Built, + GheroFieldsFragment { + GHeroWithInterfaceSubTypedFragmentsData_hero._(); + + factory GHeroWithInterfaceSubTypedFragmentsData_hero( + [Function(GHeroWithInterfaceSubTypedFragmentsData_heroBuilder b) + updates]) = _$GHeroWithInterfaceSubTypedFragmentsData_hero; + + static void _initializeBuilder( + GHeroWithInterfaceSubTypedFragmentsData_heroBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get id; + @override + String get name; + static Serializer + get serializer => _$gHeroWithInterfaceSubTypedFragmentsDataHeroSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GHeroWithInterfaceSubTypedFragmentsData_hero.serializer, + this, + ) as Map); + + static GHeroWithInterfaceSubTypedFragmentsData_hero? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GHeroWithInterfaceSubTypedFragmentsData_hero.serializer, + json, + ); +} + +abstract class GheroFieldsFragment { + String get G__typename; + String get id; + String get name; +} + +extension GheroFieldsFragmentWhenExtension on GheroFieldsFragment { + _T when<_T>({ + required _T Function(GheroFieldsFragment__asHuman) human, + required _T Function(GheroFieldsFragment__asDroid) droid, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Human': + return human((this as GheroFieldsFragment__asHuman)); + case 'Droid': + return droid((this as GheroFieldsFragment__asDroid)); + default: + return orElse(); + } + } + + _T maybeWhen<_T>({ + _T Function(GheroFieldsFragment__asHuman)? human, + _T Function(GheroFieldsFragment__asDroid)? droid, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Human': + return human != null + ? human((this as GheroFieldsFragment__asHuman)) + : orElse(); + case 'Droid': + return droid != null + ? droid((this as GheroFieldsFragment__asDroid)) + : orElse(); + default: + return orElse(); + } + } +} + +abstract class GheroFieldsFragment__base implements GheroFieldsFragment { + @override + String get G__typename; + @override + String get id; + @override + String get name; + @override + Map toJson(); +} + +abstract class GheroFieldsFragment__asHuman + implements GheroFieldsFragment, GhumanFieldsFragment { + @override + String get G__typename; + @override + String get id; + @override + String get name; + @override + String? get homePlanet; + @override + BuiltList? get friends; + @override + Map toJson(); +} + +abstract class GheroFieldsFragment__asHuman_friends + implements GhumanFieldsFragment_friends { + @override + String get G__typename; +} + +extension GheroFieldsFragment__asHuman_friendsWhenExtension + on GheroFieldsFragment__asHuman_friends { + _T when<_T>({ + required _T Function(GheroFieldsFragment__asHuman_friends__asDroid) droid, + required _T Function(GheroFieldsFragment__asHuman_friends__asHuman) human, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Droid': + return droid((this as GheroFieldsFragment__asHuman_friends__asDroid)); + case 'Human': + return human((this as GheroFieldsFragment__asHuman_friends__asHuman)); + default: + return orElse(); + } + } + + _T maybeWhen<_T>({ + _T Function(GheroFieldsFragment__asHuman_friends__asDroid)? droid, + _T Function(GheroFieldsFragment__asHuman_friends__asHuman)? human, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Droid': + return droid != null + ? droid((this as GheroFieldsFragment__asHuman_friends__asDroid)) + : orElse(); + case 'Human': + return human != null + ? human((this as GheroFieldsFragment__asHuman_friends__asHuman)) + : orElse(); + default: + return orElse(); + } + } +} + +abstract class GheroFieldsFragment__asHuman_friends__base + implements GheroFieldsFragment__asHuman_friends { + @override + String get G__typename; + @override + Map toJson(); +} + +abstract class GheroFieldsFragment__asHuman_friends__asDroid + implements GheroFieldsFragment__asHuman_friends, GdroidFieldsFragment { + @override + String get G__typename; + String get id; + String get name; + @override + String? get primaryFunction; + @override + Map toJson(); +} + +abstract class GheroFieldsFragment__asHuman_friends__asHuman + implements GheroFieldsFragment__asHuman_friends { + @override + String get G__typename; + String get id; + String get name; + String? get homePlanet; + @override + Map toJson(); +} + +abstract class GheroFieldsFragment__asDroid + implements GheroFieldsFragment, GdroidFieldsFragment { + @override + String get G__typename; + @override + String get id; + @override + String get name; + @override + String? get primaryFunction; + @override + Map toJson(); +} + +abstract class GheroFieldsFragmentData implements GheroFieldsFragment { + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get id; + @override + String get name; + static Serializer get serializer => + _i2.InlineFragmentSerializer( + 'GheroFieldsFragmentData', + GheroFieldsFragmentData__base, + { + 'Human': GheroFieldsFragmentData__asHuman, + 'Droid': GheroFieldsFragmentData__asDroid, + }, + ); + + Map toJson() => (_i1.serializers.serializeWith( + GheroFieldsFragmentData.serializer, + this, + ) as Map); + + static GheroFieldsFragmentData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GheroFieldsFragmentData.serializer, + json, + ); +} + +extension GheroFieldsFragmentDataWhenExtension on GheroFieldsFragmentData { + _T when<_T>({ + required _T Function(GheroFieldsFragmentData__asHuman) human, + required _T Function(GheroFieldsFragmentData__asDroid) droid, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Human': + return human((this as GheroFieldsFragmentData__asHuman)); + case 'Droid': + return droid((this as GheroFieldsFragmentData__asDroid)); + default: + return orElse(); + } + } + + _T maybeWhen<_T>({ + _T Function(GheroFieldsFragmentData__asHuman)? human, + _T Function(GheroFieldsFragmentData__asDroid)? droid, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Human': + return human != null + ? human((this as GheroFieldsFragmentData__asHuman)) + : orElse(); + case 'Droid': + return droid != null + ? droid((this as GheroFieldsFragmentData__asDroid)) + : orElse(); + default: + return orElse(); + } + } +} + +abstract class GheroFieldsFragmentData__base + implements + Built, + GheroFieldsFragmentData { + GheroFieldsFragmentData__base._(); + + factory GheroFieldsFragmentData__base( + [Function(GheroFieldsFragmentData__baseBuilder b) updates]) = + _$GheroFieldsFragmentData__base; + + static void _initializeBuilder(GheroFieldsFragmentData__baseBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get id; + @override + String get name; + static Serializer get serializer => + _$gheroFieldsFragmentDataBaseSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GheroFieldsFragmentData__base.serializer, + this, + ) as Map); + + static GheroFieldsFragmentData__base? fromJson(Map json) => + _i1.serializers.deserializeWith( + GheroFieldsFragmentData__base.serializer, + json, + ); +} + +abstract class GheroFieldsFragmentData__asHuman + implements + Built, + GheroFieldsFragmentData, + GhumanFieldsFragment { + GheroFieldsFragmentData__asHuman._(); + + factory GheroFieldsFragmentData__asHuman( + [Function(GheroFieldsFragmentData__asHumanBuilder b) updates]) = + _$GheroFieldsFragmentData__asHuman; + + static void _initializeBuilder(GheroFieldsFragmentData__asHumanBuilder b) => + b..G__typename = 'Human'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get id; + @override + String get name; + @override + String? get homePlanet; + @override + BuiltList? get friends; + static Serializer get serializer => + _$gheroFieldsFragmentDataAsHumanSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GheroFieldsFragmentData__asHuman.serializer, + this, + ) as Map); + + static GheroFieldsFragmentData__asHuman? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GheroFieldsFragmentData__asHuman.serializer, + json, + ); +} + +abstract class GheroFieldsFragmentData__asHuman_friends + implements GhumanFieldsFragment_friends { + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + static Serializer get serializer => + _i2.InlineFragmentSerializer( + 'GheroFieldsFragmentData__asHuman_friends', + GheroFieldsFragmentData__asHuman_friends__base, + { + 'Droid': GheroFieldsFragmentData__asHuman_friends__asDroid, + 'Human': GheroFieldsFragmentData__asHuman_friends__asHuman, + }, + ); + + Map toJson() => (_i1.serializers.serializeWith( + GheroFieldsFragmentData__asHuman_friends.serializer, + this, + ) as Map); + + static GheroFieldsFragmentData__asHuman_friends? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GheroFieldsFragmentData__asHuman_friends.serializer, + json, + ); +} + +extension GheroFieldsFragmentData__asHuman_friendsWhenExtension + on GheroFieldsFragmentData__asHuman_friends { + _T when<_T>({ + required _T Function(GheroFieldsFragmentData__asHuman_friends__asDroid) + droid, + required _T Function(GheroFieldsFragmentData__asHuman_friends__asHuman) + human, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Droid': + return droid( + (this as GheroFieldsFragmentData__asHuman_friends__asDroid)); + case 'Human': + return human( + (this as GheroFieldsFragmentData__asHuman_friends__asHuman)); + default: + return orElse(); + } + } + + _T maybeWhen<_T>({ + _T Function(GheroFieldsFragmentData__asHuman_friends__asDroid)? droid, + _T Function(GheroFieldsFragmentData__asHuman_friends__asHuman)? human, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Droid': + return droid != null + ? droid((this as GheroFieldsFragmentData__asHuman_friends__asDroid)) + : orElse(); + case 'Human': + return human != null + ? human((this as GheroFieldsFragmentData__asHuman_friends__asHuman)) + : orElse(); + default: + return orElse(); + } + } +} + +abstract class GheroFieldsFragmentData__asHuman_friends__base + implements + Built, + GheroFieldsFragmentData__asHuman_friends { + GheroFieldsFragmentData__asHuman_friends__base._(); + + factory GheroFieldsFragmentData__asHuman_friends__base( + [Function(GheroFieldsFragmentData__asHuman_friends__baseBuilder b) + updates]) = _$GheroFieldsFragmentData__asHuman_friends__base; + + static void _initializeBuilder( + GheroFieldsFragmentData__asHuman_friends__baseBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + static Serializer + get serializer => _$gheroFieldsFragmentDataAsHumanFriendsBaseSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GheroFieldsFragmentData__asHuman_friends__base.serializer, + this, + ) as Map); + + static GheroFieldsFragmentData__asHuman_friends__base? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GheroFieldsFragmentData__asHuman_friends__base.serializer, + json, + ); +} + +abstract class GheroFieldsFragmentData__asHuman_friends__asDroid + implements + Built, + GheroFieldsFragmentData__asHuman_friends, + GdroidFieldsFragment { + GheroFieldsFragmentData__asHuman_friends__asDroid._(); + + factory GheroFieldsFragmentData__asHuman_friends__asDroid( + [Function(GheroFieldsFragmentData__asHuman_friends__asDroidBuilder b) + updates]) = _$GheroFieldsFragmentData__asHuman_friends__asDroid; + + static void _initializeBuilder( + GheroFieldsFragmentData__asHuman_friends__asDroidBuilder b) => + b..G__typename = 'Droid'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + String get id; + String get name; + @override + String? get primaryFunction; + static Serializer + get serializer => + _$gheroFieldsFragmentDataAsHumanFriendsAsDroidSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GheroFieldsFragmentData__asHuman_friends__asDroid.serializer, + this, + ) as Map); + + static GheroFieldsFragmentData__asHuman_friends__asDroid? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GheroFieldsFragmentData__asHuman_friends__asDroid.serializer, + json, + ); +} + +abstract class GheroFieldsFragmentData__asHuman_friends__asHuman + implements + Built, + GheroFieldsFragmentData__asHuman_friends { + GheroFieldsFragmentData__asHuman_friends__asHuman._(); + + factory GheroFieldsFragmentData__asHuman_friends__asHuman( + [Function(GheroFieldsFragmentData__asHuman_friends__asHumanBuilder b) + updates]) = _$GheroFieldsFragmentData__asHuman_friends__asHuman; + + static void _initializeBuilder( + GheroFieldsFragmentData__asHuman_friends__asHumanBuilder b) => + b..G__typename = 'Human'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + String get id; + String get name; + String? get homePlanet; + static Serializer + get serializer => + _$gheroFieldsFragmentDataAsHumanFriendsAsHumanSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GheroFieldsFragmentData__asHuman_friends__asHuman.serializer, + this, + ) as Map); + + static GheroFieldsFragmentData__asHuman_friends__asHuman? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GheroFieldsFragmentData__asHuman_friends__asHuman.serializer, + json, + ); +} + +abstract class GheroFieldsFragmentData__asDroid + implements + Built, + GheroFieldsFragmentData, + GdroidFieldsFragment { + GheroFieldsFragmentData__asDroid._(); + + factory GheroFieldsFragmentData__asDroid( + [Function(GheroFieldsFragmentData__asDroidBuilder b) updates]) = + _$GheroFieldsFragmentData__asDroid; + + static void _initializeBuilder(GheroFieldsFragmentData__asDroidBuilder b) => + b..G__typename = 'Droid'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get id; + @override + String get name; + @override + String? get primaryFunction; + static Serializer get serializer => + _$gheroFieldsFragmentDataAsDroidSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GheroFieldsFragmentData__asDroid.serializer, + this, + ) as Map); + + static GheroFieldsFragmentData__asDroid? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GheroFieldsFragmentData__asDroid.serializer, + json, + ); +} + +abstract class GhumanFieldsFragment { + String get G__typename; + String? get homePlanet; + BuiltList? get friends; + Map toJson(); +} + +abstract class GhumanFieldsFragment_friends { + String get G__typename; +} + +extension GhumanFieldsFragment_friendsWhenExtension + on GhumanFieldsFragment_friends { + _T when<_T>({ + required _T Function(GhumanFieldsFragment_friends__asDroid) droid, + required _T Function(GhumanFieldsFragment_friends__asHuman) human, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Droid': + return droid((this as GhumanFieldsFragment_friends__asDroid)); + case 'Human': + return human((this as GhumanFieldsFragment_friends__asHuman)); + default: + return orElse(); + } + } + + _T maybeWhen<_T>({ + _T Function(GhumanFieldsFragment_friends__asDroid)? droid, + _T Function(GhumanFieldsFragment_friends__asHuman)? human, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Droid': + return droid != null + ? droid((this as GhumanFieldsFragment_friends__asDroid)) + : orElse(); + case 'Human': + return human != null + ? human((this as GhumanFieldsFragment_friends__asHuman)) + : orElse(); + default: + return orElse(); + } + } +} + +abstract class GhumanFieldsFragment_friends__base + implements GhumanFieldsFragment_friends { + @override + String get G__typename; + @override + Map toJson(); +} + +abstract class GhumanFieldsFragment_friends__asDroid + implements GhumanFieldsFragment_friends, GdroidFieldsFragment { + @override + String get G__typename; + String get id; + String get name; + @override + String? get primaryFunction; + @override + Map toJson(); +} + +abstract class GhumanFieldsFragment_friends__asHuman + implements GhumanFieldsFragment_friends { + @override + String get G__typename; + String get id; + String get name; + String? get homePlanet; + @override + Map toJson(); +} + +abstract class GhumanFieldsFragmentData + implements + Built, + GhumanFieldsFragment { + GhumanFieldsFragmentData._(); + + factory GhumanFieldsFragmentData( + [Function(GhumanFieldsFragmentDataBuilder b) updates]) = + _$GhumanFieldsFragmentData; + + static void _initializeBuilder(GhumanFieldsFragmentDataBuilder b) => + b..G__typename = 'Human'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String? get homePlanet; + @override + BuiltList? get friends; + static Serializer get serializer => + _$ghumanFieldsFragmentDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GhumanFieldsFragmentData.serializer, + this, + ) as Map); + + static GhumanFieldsFragmentData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GhumanFieldsFragmentData.serializer, + json, + ); +} + +abstract class GhumanFieldsFragmentData_friends + implements GhumanFieldsFragment_friends { + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + static Serializer get serializer => + _i2.InlineFragmentSerializer( + 'GhumanFieldsFragmentData_friends', + GhumanFieldsFragmentData_friends__base, + { + 'Droid': GhumanFieldsFragmentData_friends__asDroid, + 'Human': GhumanFieldsFragmentData_friends__asHuman, + }, + ); + + Map toJson() => (_i1.serializers.serializeWith( + GhumanFieldsFragmentData_friends.serializer, + this, + ) as Map); + + static GhumanFieldsFragmentData_friends? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GhumanFieldsFragmentData_friends.serializer, + json, + ); +} + +extension GhumanFieldsFragmentData_friendsWhenExtension + on GhumanFieldsFragmentData_friends { + _T when<_T>({ + required _T Function(GhumanFieldsFragmentData_friends__asDroid) droid, + required _T Function(GhumanFieldsFragmentData_friends__asHuman) human, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Droid': + return droid((this as GhumanFieldsFragmentData_friends__asDroid)); + case 'Human': + return human((this as GhumanFieldsFragmentData_friends__asHuman)); + default: + return orElse(); + } + } + + _T maybeWhen<_T>({ + _T Function(GhumanFieldsFragmentData_friends__asDroid)? droid, + _T Function(GhumanFieldsFragmentData_friends__asHuman)? human, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Droid': + return droid != null + ? droid((this as GhumanFieldsFragmentData_friends__asDroid)) + : orElse(); + case 'Human': + return human != null + ? human((this as GhumanFieldsFragmentData_friends__asHuman)) + : orElse(); + default: + return orElse(); + } + } +} + +abstract class GhumanFieldsFragmentData_friends__base + implements + Built, + GhumanFieldsFragmentData_friends { + GhumanFieldsFragmentData_friends__base._(); + + factory GhumanFieldsFragmentData_friends__base( + [Function(GhumanFieldsFragmentData_friends__baseBuilder b) updates]) = + _$GhumanFieldsFragmentData_friends__base; + + static void _initializeBuilder( + GhumanFieldsFragmentData_friends__baseBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + static Serializer get serializer => + _$ghumanFieldsFragmentDataFriendsBaseSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GhumanFieldsFragmentData_friends__base.serializer, + this, + ) as Map); + + static GhumanFieldsFragmentData_friends__base? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GhumanFieldsFragmentData_friends__base.serializer, + json, + ); +} + +abstract class GhumanFieldsFragmentData_friends__asDroid + implements + Built, + GhumanFieldsFragmentData_friends, + GdroidFieldsFragment { + GhumanFieldsFragmentData_friends__asDroid._(); + + factory GhumanFieldsFragmentData_friends__asDroid( + [Function(GhumanFieldsFragmentData_friends__asDroidBuilder b) + updates]) = _$GhumanFieldsFragmentData_friends__asDroid; + + static void _initializeBuilder( + GhumanFieldsFragmentData_friends__asDroidBuilder b) => + b..G__typename = 'Droid'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + String get id; + String get name; + @override + String? get primaryFunction; + static Serializer get serializer => + _$ghumanFieldsFragmentDataFriendsAsDroidSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GhumanFieldsFragmentData_friends__asDroid.serializer, + this, + ) as Map); + + static GhumanFieldsFragmentData_friends__asDroid? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GhumanFieldsFragmentData_friends__asDroid.serializer, + json, + ); +} + +abstract class GhumanFieldsFragmentData_friends__asHuman + implements + Built, + GhumanFieldsFragmentData_friends { + GhumanFieldsFragmentData_friends__asHuman._(); + + factory GhumanFieldsFragmentData_friends__asHuman( + [Function(GhumanFieldsFragmentData_friends__asHumanBuilder b) + updates]) = _$GhumanFieldsFragmentData_friends__asHuman; + + static void _initializeBuilder( + GhumanFieldsFragmentData_friends__asHumanBuilder b) => + b..G__typename = 'Human'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + String get id; + String get name; + String? get homePlanet; + static Serializer get serializer => + _$ghumanFieldsFragmentDataFriendsAsHumanSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GhumanFieldsFragmentData_friends__asHuman.serializer, + this, + ) as Map); + + static GhumanFieldsFragmentData_friends__asHuman? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GhumanFieldsFragmentData_friends__asHuman.serializer, + json, + ); +} + +abstract class GdroidFieldsFragment { + String get G__typename; + String? get primaryFunction; + Map toJson(); +} + +abstract class GdroidFieldsFragmentData + implements + Built, + GdroidFieldsFragment { + GdroidFieldsFragmentData._(); + + factory GdroidFieldsFragmentData( + [Function(GdroidFieldsFragmentDataBuilder b) updates]) = + _$GdroidFieldsFragmentData; + + static void _initializeBuilder(GdroidFieldsFragmentDataBuilder b) => + b..G__typename = 'Droid'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String? get primaryFunction; + static Serializer get serializer => + _$gdroidFieldsFragmentDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GdroidFieldsFragmentData.serializer, + this, + ) as Map); + + static GdroidFieldsFragmentData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GdroidFieldsFragmentData.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.g.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.g.dart new file mode 100644 index 00000000..20c08793 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.g.dart @@ -0,0 +1,2592 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'hero_with_interface_subtyped_fragments.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer + _$gHeroWithInterfaceSubTypedFragmentsDataSerializer = + new _$GHeroWithInterfaceSubTypedFragmentsDataSerializer(); +Serializer + _$gHeroWithInterfaceSubTypedFragmentsDataHeroSerializer = + new _$GHeroWithInterfaceSubTypedFragmentsData_heroSerializer(); +Serializer + _$gheroFieldsFragmentDataBaseSerializer = + new _$GheroFieldsFragmentData__baseSerializer(); +Serializer + _$gheroFieldsFragmentDataAsHumanSerializer = + new _$GheroFieldsFragmentData__asHumanSerializer(); +Serializer + _$gheroFieldsFragmentDataAsHumanFriendsBaseSerializer = + new _$GheroFieldsFragmentData__asHuman_friends__baseSerializer(); +Serializer + _$gheroFieldsFragmentDataAsHumanFriendsAsDroidSerializer = + new _$GheroFieldsFragmentData__asHuman_friends__asDroidSerializer(); +Serializer + _$gheroFieldsFragmentDataAsHumanFriendsAsHumanSerializer = + new _$GheroFieldsFragmentData__asHuman_friends__asHumanSerializer(); +Serializer + _$gheroFieldsFragmentDataAsDroidSerializer = + new _$GheroFieldsFragmentData__asDroidSerializer(); +Serializer _$ghumanFieldsFragmentDataSerializer = + new _$GhumanFieldsFragmentDataSerializer(); +Serializer + _$ghumanFieldsFragmentDataFriendsBaseSerializer = + new _$GhumanFieldsFragmentData_friends__baseSerializer(); +Serializer + _$ghumanFieldsFragmentDataFriendsAsDroidSerializer = + new _$GhumanFieldsFragmentData_friends__asDroidSerializer(); +Serializer + _$ghumanFieldsFragmentDataFriendsAsHumanSerializer = + new _$GhumanFieldsFragmentData_friends__asHumanSerializer(); +Serializer _$gdroidFieldsFragmentDataSerializer = + new _$GdroidFieldsFragmentDataSerializer(); + +class _$GHeroWithInterfaceSubTypedFragmentsDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroWithInterfaceSubTypedFragmentsData, + _$GHeroWithInterfaceSubTypedFragmentsData + ]; + @override + final String wireName = 'GHeroWithInterfaceSubTypedFragmentsData'; + + @override + Iterable serialize( + Serializers serializers, GHeroWithInterfaceSubTypedFragmentsData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.hero; + if (value != null) { + result + ..add('hero') + ..add(serializers.serialize(value, + specifiedType: + const FullType(GHeroWithInterfaceSubTypedFragmentsData_hero))); + } + return result; + } + + @override + GHeroWithInterfaceSubTypedFragmentsData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroWithInterfaceSubTypedFragmentsDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'hero': + result.hero.replace(serializers.deserialize(value, + specifiedType: const FullType( + GHeroWithInterfaceSubTypedFragmentsData_hero))! + as GHeroWithInterfaceSubTypedFragmentsData_hero); + break; + } + } + + return result.build(); + } +} + +class _$GHeroWithInterfaceSubTypedFragmentsData_heroSerializer + implements + StructuredSerializer { + @override + final Iterable types = const [ + GHeroWithInterfaceSubTypedFragmentsData_hero, + _$GHeroWithInterfaceSubTypedFragmentsData_hero + ]; + @override + final String wireName = 'GHeroWithInterfaceSubTypedFragmentsData_hero'; + + @override + Iterable serialize(Serializers serializers, + GHeroWithInterfaceSubTypedFragmentsData_hero object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GHeroWithInterfaceSubTypedFragmentsData_hero deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroWithInterfaceSubTypedFragmentsData_heroBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GheroFieldsFragmentData__baseSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GheroFieldsFragmentData__base, + _$GheroFieldsFragmentData__base + ]; + @override + final String wireName = 'GheroFieldsFragmentData__base'; + + @override + Iterable serialize( + Serializers serializers, GheroFieldsFragmentData__base object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GheroFieldsFragmentData__base deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GheroFieldsFragmentData__baseBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GheroFieldsFragmentData__asHumanSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GheroFieldsFragmentData__asHuman, + _$GheroFieldsFragmentData__asHuman + ]; + @override + final String wireName = 'GheroFieldsFragmentData__asHuman'; + + @override + Iterable serialize( + Serializers serializers, GheroFieldsFragmentData__asHuman object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.homePlanet; + if (value != null) { + result + ..add('homePlanet') + ..add(serializers.serialize(value, + specifiedType: const FullType(String))); + } + value = object.friends; + if (value != null) { + result + ..add('friends') + ..add(serializers.serialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable(GheroFieldsFragmentData__asHuman_friends) + ]))); + } + return result; + } + + @override + GheroFieldsFragmentData__asHuman deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GheroFieldsFragmentData__asHumanBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'homePlanet': + result.homePlanet = serializers.deserialize(value, + specifiedType: const FullType(String)) as String?; + break; + case 'friends': + result.friends.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable( + GheroFieldsFragmentData__asHuman_friends) + ]))! as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$GheroFieldsFragmentData__asHuman_friends__baseSerializer + implements + StructuredSerializer { + @override + final Iterable types = const [ + GheroFieldsFragmentData__asHuman_friends__base, + _$GheroFieldsFragmentData__asHuman_friends__base + ]; + @override + final String wireName = 'GheroFieldsFragmentData__asHuman_friends__base'; + + @override + Iterable serialize(Serializers serializers, + GheroFieldsFragmentData__asHuman_friends__base object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GheroFieldsFragmentData__asHuman_friends__base deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GheroFieldsFragmentData__asHuman_friends__baseBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GheroFieldsFragmentData__asHuman_friends__asDroidSerializer + implements + StructuredSerializer< + GheroFieldsFragmentData__asHuman_friends__asDroid> { + @override + final Iterable types = const [ + GheroFieldsFragmentData__asHuman_friends__asDroid, + _$GheroFieldsFragmentData__asHuman_friends__asDroid + ]; + @override + final String wireName = 'GheroFieldsFragmentData__asHuman_friends__asDroid'; + + @override + Iterable serialize(Serializers serializers, + GheroFieldsFragmentData__asHuman_friends__asDroid object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.primaryFunction; + if (value != null) { + result + ..add('primaryFunction') + ..add(serializers.serialize(value, + specifiedType: const FullType(String))); + } + return result; + } + + @override + GheroFieldsFragmentData__asHuman_friends__asDroid deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = + new GheroFieldsFragmentData__asHuman_friends__asDroidBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'primaryFunction': + result.primaryFunction = serializers.deserialize(value, + specifiedType: const FullType(String)) as String?; + break; + } + } + + return result.build(); + } +} + +class _$GheroFieldsFragmentData__asHuman_friends__asHumanSerializer + implements + StructuredSerializer< + GheroFieldsFragmentData__asHuman_friends__asHuman> { + @override + final Iterable types = const [ + GheroFieldsFragmentData__asHuman_friends__asHuman, + _$GheroFieldsFragmentData__asHuman_friends__asHuman + ]; + @override + final String wireName = 'GheroFieldsFragmentData__asHuman_friends__asHuman'; + + @override + Iterable serialize(Serializers serializers, + GheroFieldsFragmentData__asHuman_friends__asHuman object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.homePlanet; + if (value != null) { + result + ..add('homePlanet') + ..add(serializers.serialize(value, + specifiedType: const FullType(String))); + } + return result; + } + + @override + GheroFieldsFragmentData__asHuman_friends__asHuman deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = + new GheroFieldsFragmentData__asHuman_friends__asHumanBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'homePlanet': + result.homePlanet = serializers.deserialize(value, + specifiedType: const FullType(String)) as String?; + break; + } + } + + return result.build(); + } +} + +class _$GheroFieldsFragmentData__asDroidSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GheroFieldsFragmentData__asDroid, + _$GheroFieldsFragmentData__asDroid + ]; + @override + final String wireName = 'GheroFieldsFragmentData__asDroid'; + + @override + Iterable serialize( + Serializers serializers, GheroFieldsFragmentData__asDroid object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.primaryFunction; + if (value != null) { + result + ..add('primaryFunction') + ..add(serializers.serialize(value, + specifiedType: const FullType(String))); + } + return result; + } + + @override + GheroFieldsFragmentData__asDroid deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GheroFieldsFragmentData__asDroidBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'primaryFunction': + result.primaryFunction = serializers.deserialize(value, + specifiedType: const FullType(String)) as String?; + break; + } + } + + return result.build(); + } +} + +class _$GhumanFieldsFragmentDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GhumanFieldsFragmentData, + _$GhumanFieldsFragmentData + ]; + @override + final String wireName = 'GhumanFieldsFragmentData'; + + @override + Iterable serialize( + Serializers serializers, GhumanFieldsFragmentData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.homePlanet; + if (value != null) { + result + ..add('homePlanet') + ..add(serializers.serialize(value, + specifiedType: const FullType(String))); + } + value = object.friends; + if (value != null) { + result + ..add('friends') + ..add(serializers.serialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable(GhumanFieldsFragmentData_friends) + ]))); + } + return result; + } + + @override + GhumanFieldsFragmentData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GhumanFieldsFragmentDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'homePlanet': + result.homePlanet = serializers.deserialize(value, + specifiedType: const FullType(String)) as String?; + break; + case 'friends': + result.friends.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable(GhumanFieldsFragmentData_friends) + ]))! as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$GhumanFieldsFragmentData_friends__baseSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GhumanFieldsFragmentData_friends__base, + _$GhumanFieldsFragmentData_friends__base + ]; + @override + final String wireName = 'GhumanFieldsFragmentData_friends__base'; + + @override + Iterable serialize( + Serializers serializers, GhumanFieldsFragmentData_friends__base object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GhumanFieldsFragmentData_friends__base deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GhumanFieldsFragmentData_friends__baseBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GhumanFieldsFragmentData_friends__asDroidSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GhumanFieldsFragmentData_friends__asDroid, + _$GhumanFieldsFragmentData_friends__asDroid + ]; + @override + final String wireName = 'GhumanFieldsFragmentData_friends__asDroid'; + + @override + Iterable serialize( + Serializers serializers, GhumanFieldsFragmentData_friends__asDroid object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.primaryFunction; + if (value != null) { + result + ..add('primaryFunction') + ..add(serializers.serialize(value, + specifiedType: const FullType(String))); + } + return result; + } + + @override + GhumanFieldsFragmentData_friends__asDroid deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GhumanFieldsFragmentData_friends__asDroidBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'primaryFunction': + result.primaryFunction = serializers.deserialize(value, + specifiedType: const FullType(String)) as String?; + break; + } + } + + return result.build(); + } +} + +class _$GhumanFieldsFragmentData_friends__asHumanSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GhumanFieldsFragmentData_friends__asHuman, + _$GhumanFieldsFragmentData_friends__asHuman + ]; + @override + final String wireName = 'GhumanFieldsFragmentData_friends__asHuman'; + + @override + Iterable serialize( + Serializers serializers, GhumanFieldsFragmentData_friends__asHuman object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.homePlanet; + if (value != null) { + result + ..add('homePlanet') + ..add(serializers.serialize(value, + specifiedType: const FullType(String))); + } + return result; + } + + @override + GhumanFieldsFragmentData_friends__asHuman deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GhumanFieldsFragmentData_friends__asHumanBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'homePlanet': + result.homePlanet = serializers.deserialize(value, + specifiedType: const FullType(String)) as String?; + break; + } + } + + return result.build(); + } +} + +class _$GdroidFieldsFragmentDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GdroidFieldsFragmentData, + _$GdroidFieldsFragmentData + ]; + @override + final String wireName = 'GdroidFieldsFragmentData'; + + @override + Iterable serialize( + Serializers serializers, GdroidFieldsFragmentData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.primaryFunction; + if (value != null) { + result + ..add('primaryFunction') + ..add(serializers.serialize(value, + specifiedType: const FullType(String))); + } + return result; + } + + @override + GdroidFieldsFragmentData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GdroidFieldsFragmentDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'primaryFunction': + result.primaryFunction = serializers.deserialize(value, + specifiedType: const FullType(String)) as String?; + break; + } + } + + return result.build(); + } +} + +class _$GHeroWithInterfaceSubTypedFragmentsData + extends GHeroWithInterfaceSubTypedFragmentsData { + @override + final String G__typename; + @override + final GHeroWithInterfaceSubTypedFragmentsData_hero? hero; + + factory _$GHeroWithInterfaceSubTypedFragmentsData( + [void Function(GHeroWithInterfaceSubTypedFragmentsDataBuilder)? + updates]) => + (new GHeroWithInterfaceSubTypedFragmentsDataBuilder()..update(updates)) + ._build(); + + _$GHeroWithInterfaceSubTypedFragmentsData._( + {required this.G__typename, this.hero}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroWithInterfaceSubTypedFragmentsData', 'G__typename'); + } + + @override + GHeroWithInterfaceSubTypedFragmentsData rebuild( + void Function(GHeroWithInterfaceSubTypedFragmentsDataBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWithInterfaceSubTypedFragmentsDataBuilder toBuilder() => + new GHeroWithInterfaceSubTypedFragmentsDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWithInterfaceSubTypedFragmentsData && + G__typename == other.G__typename && + hero == other.hero; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, hero.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GHeroWithInterfaceSubTypedFragmentsData') + ..add('G__typename', G__typename) + ..add('hero', hero)) + .toString(); + } +} + +class GHeroWithInterfaceSubTypedFragmentsDataBuilder + implements + Builder { + _$GHeroWithInterfaceSubTypedFragmentsData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GHeroWithInterfaceSubTypedFragmentsData_heroBuilder? _hero; + GHeroWithInterfaceSubTypedFragmentsData_heroBuilder get hero => + _$this._hero ??= + new GHeroWithInterfaceSubTypedFragmentsData_heroBuilder(); + set hero(GHeroWithInterfaceSubTypedFragmentsData_heroBuilder? hero) => + _$this._hero = hero; + + GHeroWithInterfaceSubTypedFragmentsDataBuilder() { + GHeroWithInterfaceSubTypedFragmentsData._initializeBuilder(this); + } + + GHeroWithInterfaceSubTypedFragmentsDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _hero = $v.hero?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GHeroWithInterfaceSubTypedFragmentsData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWithInterfaceSubTypedFragmentsData; + } + + @override + void update( + void Function(GHeroWithInterfaceSubTypedFragmentsDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroWithInterfaceSubTypedFragmentsData build() => _build(); + + _$GHeroWithInterfaceSubTypedFragmentsData _build() { + _$GHeroWithInterfaceSubTypedFragmentsData _$result; + try { + _$result = _$v ?? + new _$GHeroWithInterfaceSubTypedFragmentsData._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GHeroWithInterfaceSubTypedFragmentsData', 'G__typename'), + hero: _hero?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'hero'; + _hero?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroWithInterfaceSubTypedFragmentsData', + _$failedField, + e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GHeroWithInterfaceSubTypedFragmentsData_hero + extends GHeroWithInterfaceSubTypedFragmentsData_hero { + @override + final String G__typename; + @override + final String id; + @override + final String name; + + factory _$GHeroWithInterfaceSubTypedFragmentsData_hero( + [void Function(GHeroWithInterfaceSubTypedFragmentsData_heroBuilder)? + updates]) => + (new GHeroWithInterfaceSubTypedFragmentsData_heroBuilder() + ..update(updates)) + ._build(); + + _$GHeroWithInterfaceSubTypedFragmentsData_hero._( + {required this.G__typename, required this.id, required this.name}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GHeroWithInterfaceSubTypedFragmentsData_hero', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + id, r'GHeroWithInterfaceSubTypedFragmentsData_hero', 'id'); + BuiltValueNullFieldError.checkNotNull( + name, r'GHeroWithInterfaceSubTypedFragmentsData_hero', 'name'); + } + + @override + GHeroWithInterfaceSubTypedFragmentsData_hero rebuild( + void Function(GHeroWithInterfaceSubTypedFragmentsData_heroBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWithInterfaceSubTypedFragmentsData_heroBuilder toBuilder() => + new GHeroWithInterfaceSubTypedFragmentsData_heroBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWithInterfaceSubTypedFragmentsData_hero && + G__typename == other.G__typename && + id == other.id && + name == other.name; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GHeroWithInterfaceSubTypedFragmentsData_hero') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('name', name)) + .toString(); + } +} + +class GHeroWithInterfaceSubTypedFragmentsData_heroBuilder + implements + Builder { + _$GHeroWithInterfaceSubTypedFragmentsData_hero? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + GHeroWithInterfaceSubTypedFragmentsData_heroBuilder() { + GHeroWithInterfaceSubTypedFragmentsData_hero._initializeBuilder(this); + } + + GHeroWithInterfaceSubTypedFragmentsData_heroBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _name = $v.name; + _$v = null; + } + return this; + } + + @override + void replace(GHeroWithInterfaceSubTypedFragmentsData_hero other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWithInterfaceSubTypedFragmentsData_hero; + } + + @override + void update( + void Function(GHeroWithInterfaceSubTypedFragmentsData_heroBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GHeroWithInterfaceSubTypedFragmentsData_hero build() => _build(); + + _$GHeroWithInterfaceSubTypedFragmentsData_hero _build() { + final _$result = _$v ?? + new _$GHeroWithInterfaceSubTypedFragmentsData_hero._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GHeroWithInterfaceSubTypedFragmentsData_hero', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GHeroWithInterfaceSubTypedFragmentsData_hero', 'id'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GHeroWithInterfaceSubTypedFragmentsData_hero', 'name')); + replace(_$result); + return _$result; + } +} + +class _$GheroFieldsFragmentData__base extends GheroFieldsFragmentData__base { + @override + final String G__typename; + @override + final String id; + @override + final String name; + + factory _$GheroFieldsFragmentData__base( + [void Function(GheroFieldsFragmentData__baseBuilder)? updates]) => + (new GheroFieldsFragmentData__baseBuilder()..update(updates))._build(); + + _$GheroFieldsFragmentData__base._( + {required this.G__typename, required this.id, required this.name}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GheroFieldsFragmentData__base', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + id, r'GheroFieldsFragmentData__base', 'id'); + BuiltValueNullFieldError.checkNotNull( + name, r'GheroFieldsFragmentData__base', 'name'); + } + + @override + GheroFieldsFragmentData__base rebuild( + void Function(GheroFieldsFragmentData__baseBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GheroFieldsFragmentData__baseBuilder toBuilder() => + new GheroFieldsFragmentData__baseBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GheroFieldsFragmentData__base && + G__typename == other.G__typename && + id == other.id && + name == other.name; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GheroFieldsFragmentData__base') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('name', name)) + .toString(); + } +} + +class GheroFieldsFragmentData__baseBuilder + implements + Builder { + _$GheroFieldsFragmentData__base? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + GheroFieldsFragmentData__baseBuilder() { + GheroFieldsFragmentData__base._initializeBuilder(this); + } + + GheroFieldsFragmentData__baseBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _name = $v.name; + _$v = null; + } + return this; + } + + @override + void replace(GheroFieldsFragmentData__base other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GheroFieldsFragmentData__base; + } + + @override + void update(void Function(GheroFieldsFragmentData__baseBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GheroFieldsFragmentData__base build() => _build(); + + _$GheroFieldsFragmentData__base _build() { + final _$result = _$v ?? + new _$GheroFieldsFragmentData__base._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GheroFieldsFragmentData__base', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GheroFieldsFragmentData__base', 'id'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GheroFieldsFragmentData__base', 'name')); + replace(_$result); + return _$result; + } +} + +class _$GheroFieldsFragmentData__asHuman + extends GheroFieldsFragmentData__asHuman { + @override + final String G__typename; + @override + final String id; + @override + final String name; + @override + final String? homePlanet; + @override + final BuiltList? friends; + + factory _$GheroFieldsFragmentData__asHuman( + [void Function(GheroFieldsFragmentData__asHumanBuilder)? updates]) => + (new GheroFieldsFragmentData__asHumanBuilder()..update(updates))._build(); + + _$GheroFieldsFragmentData__asHuman._( + {required this.G__typename, + required this.id, + required this.name, + this.homePlanet, + this.friends}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GheroFieldsFragmentData__asHuman', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + id, r'GheroFieldsFragmentData__asHuman', 'id'); + BuiltValueNullFieldError.checkNotNull( + name, r'GheroFieldsFragmentData__asHuman', 'name'); + } + + @override + GheroFieldsFragmentData__asHuman rebuild( + void Function(GheroFieldsFragmentData__asHumanBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GheroFieldsFragmentData__asHumanBuilder toBuilder() => + new GheroFieldsFragmentData__asHumanBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GheroFieldsFragmentData__asHuman && + G__typename == other.G__typename && + id == other.id && + name == other.name && + homePlanet == other.homePlanet && + friends == other.friends; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, homePlanet.hashCode); + _$hash = $jc(_$hash, friends.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GheroFieldsFragmentData__asHuman') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('name', name) + ..add('homePlanet', homePlanet) + ..add('friends', friends)) + .toString(); + } +} + +class GheroFieldsFragmentData__asHumanBuilder + implements + Builder { + _$GheroFieldsFragmentData__asHuman? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + String? _homePlanet; + String? get homePlanet => _$this._homePlanet; + set homePlanet(String? homePlanet) => _$this._homePlanet = homePlanet; + + ListBuilder? _friends; + ListBuilder get friends => + _$this._friends ??= + new ListBuilder(); + set friends( + ListBuilder? friends) => + _$this._friends = friends; + + GheroFieldsFragmentData__asHumanBuilder() { + GheroFieldsFragmentData__asHuman._initializeBuilder(this); + } + + GheroFieldsFragmentData__asHumanBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _name = $v.name; + _homePlanet = $v.homePlanet; + _friends = $v.friends?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GheroFieldsFragmentData__asHuman other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GheroFieldsFragmentData__asHuman; + } + + @override + void update(void Function(GheroFieldsFragmentData__asHumanBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GheroFieldsFragmentData__asHuman build() => _build(); + + _$GheroFieldsFragmentData__asHuman _build() { + _$GheroFieldsFragmentData__asHuman _$result; + try { + _$result = _$v ?? + new _$GheroFieldsFragmentData__asHuman._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GheroFieldsFragmentData__asHuman', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GheroFieldsFragmentData__asHuman', 'id'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GheroFieldsFragmentData__asHuman', 'name'), + homePlanet: homePlanet, + friends: _friends?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'friends'; + _friends?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GheroFieldsFragmentData__asHuman', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GheroFieldsFragmentData__asHuman_friends__base + extends GheroFieldsFragmentData__asHuman_friends__base { + @override + final String G__typename; + + factory _$GheroFieldsFragmentData__asHuman_friends__base( + [void Function(GheroFieldsFragmentData__asHuman_friends__baseBuilder)? + updates]) => + (new GheroFieldsFragmentData__asHuman_friends__baseBuilder() + ..update(updates)) + ._build(); + + _$GheroFieldsFragmentData__asHuman_friends__base._( + {required this.G__typename}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GheroFieldsFragmentData__asHuman_friends__base', 'G__typename'); + } + + @override + GheroFieldsFragmentData__asHuman_friends__base rebuild( + void Function(GheroFieldsFragmentData__asHuman_friends__baseBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GheroFieldsFragmentData__asHuman_friends__baseBuilder toBuilder() => + new GheroFieldsFragmentData__asHuman_friends__baseBuilder() + ..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GheroFieldsFragmentData__asHuman_friends__base && + G__typename == other.G__typename; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GheroFieldsFragmentData__asHuman_friends__base') + ..add('G__typename', G__typename)) + .toString(); + } +} + +class GheroFieldsFragmentData__asHuman_friends__baseBuilder + implements + Builder { + _$GheroFieldsFragmentData__asHuman_friends__base? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GheroFieldsFragmentData__asHuman_friends__baseBuilder() { + GheroFieldsFragmentData__asHuman_friends__base._initializeBuilder(this); + } + + GheroFieldsFragmentData__asHuman_friends__baseBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _$v = null; + } + return this; + } + + @override + void replace(GheroFieldsFragmentData__asHuman_friends__base other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GheroFieldsFragmentData__asHuman_friends__base; + } + + @override + void update( + void Function(GheroFieldsFragmentData__asHuman_friends__baseBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GheroFieldsFragmentData__asHuman_friends__base build() => _build(); + + _$GheroFieldsFragmentData__asHuman_friends__base _build() { + final _$result = _$v ?? + new _$GheroFieldsFragmentData__asHuman_friends__base._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, + r'GheroFieldsFragmentData__asHuman_friends__base', + 'G__typename')); + replace(_$result); + return _$result; + } +} + +class _$GheroFieldsFragmentData__asHuman_friends__asDroid + extends GheroFieldsFragmentData__asHuman_friends__asDroid { + @override + final String G__typename; + @override + final String id; + @override + final String name; + @override + final String? primaryFunction; + + factory _$GheroFieldsFragmentData__asHuman_friends__asDroid( + [void Function( + GheroFieldsFragmentData__asHuman_friends__asDroidBuilder)? + updates]) => + (new GheroFieldsFragmentData__asHuman_friends__asDroidBuilder() + ..update(updates)) + ._build(); + + _$GheroFieldsFragmentData__asHuman_friends__asDroid._( + {required this.G__typename, + required this.id, + required this.name, + this.primaryFunction}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GheroFieldsFragmentData__asHuman_friends__asDroid', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + id, r'GheroFieldsFragmentData__asHuman_friends__asDroid', 'id'); + BuiltValueNullFieldError.checkNotNull( + name, r'GheroFieldsFragmentData__asHuman_friends__asDroid', 'name'); + } + + @override + GheroFieldsFragmentData__asHuman_friends__asDroid rebuild( + void Function( + GheroFieldsFragmentData__asHuman_friends__asDroidBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GheroFieldsFragmentData__asHuman_friends__asDroidBuilder toBuilder() => + new GheroFieldsFragmentData__asHuman_friends__asDroidBuilder() + ..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GheroFieldsFragmentData__asHuman_friends__asDroid && + G__typename == other.G__typename && + id == other.id && + name == other.name && + primaryFunction == other.primaryFunction; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, primaryFunction.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GheroFieldsFragmentData__asHuman_friends__asDroid') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('name', name) + ..add('primaryFunction', primaryFunction)) + .toString(); + } +} + +class GheroFieldsFragmentData__asHuman_friends__asDroidBuilder + implements + Builder { + _$GheroFieldsFragmentData__asHuman_friends__asDroid? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + String? _primaryFunction; + String? get primaryFunction => _$this._primaryFunction; + set primaryFunction(String? primaryFunction) => + _$this._primaryFunction = primaryFunction; + + GheroFieldsFragmentData__asHuman_friends__asDroidBuilder() { + GheroFieldsFragmentData__asHuman_friends__asDroid._initializeBuilder(this); + } + + GheroFieldsFragmentData__asHuman_friends__asDroidBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _name = $v.name; + _primaryFunction = $v.primaryFunction; + _$v = null; + } + return this; + } + + @override + void replace(GheroFieldsFragmentData__asHuman_friends__asDroid other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GheroFieldsFragmentData__asHuman_friends__asDroid; + } + + @override + void update( + void Function(GheroFieldsFragmentData__asHuman_friends__asDroidBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GheroFieldsFragmentData__asHuman_friends__asDroid build() => _build(); + + _$GheroFieldsFragmentData__asHuman_friends__asDroid _build() { + final _$result = _$v ?? + new _$GheroFieldsFragmentData__asHuman_friends__asDroid._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, + r'GheroFieldsFragmentData__asHuman_friends__asDroid', + 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GheroFieldsFragmentData__asHuman_friends__asDroid', 'id'), + name: BuiltValueNullFieldError.checkNotNull(name, + r'GheroFieldsFragmentData__asHuman_friends__asDroid', 'name'), + primaryFunction: primaryFunction); + replace(_$result); + return _$result; + } +} + +class _$GheroFieldsFragmentData__asHuman_friends__asHuman + extends GheroFieldsFragmentData__asHuman_friends__asHuman { + @override + final String G__typename; + @override + final String id; + @override + final String name; + @override + final String? homePlanet; + + factory _$GheroFieldsFragmentData__asHuman_friends__asHuman( + [void Function( + GheroFieldsFragmentData__asHuman_friends__asHumanBuilder)? + updates]) => + (new GheroFieldsFragmentData__asHuman_friends__asHumanBuilder() + ..update(updates)) + ._build(); + + _$GheroFieldsFragmentData__asHuman_friends__asHuman._( + {required this.G__typename, + required this.id, + required this.name, + this.homePlanet}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GheroFieldsFragmentData__asHuman_friends__asHuman', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + id, r'GheroFieldsFragmentData__asHuman_friends__asHuman', 'id'); + BuiltValueNullFieldError.checkNotNull( + name, r'GheroFieldsFragmentData__asHuman_friends__asHuman', 'name'); + } + + @override + GheroFieldsFragmentData__asHuman_friends__asHuman rebuild( + void Function( + GheroFieldsFragmentData__asHuman_friends__asHumanBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GheroFieldsFragmentData__asHuman_friends__asHumanBuilder toBuilder() => + new GheroFieldsFragmentData__asHuman_friends__asHumanBuilder() + ..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GheroFieldsFragmentData__asHuman_friends__asHuman && + G__typename == other.G__typename && + id == other.id && + name == other.name && + homePlanet == other.homePlanet; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, homePlanet.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GheroFieldsFragmentData__asHuman_friends__asHuman') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('name', name) + ..add('homePlanet', homePlanet)) + .toString(); + } +} + +class GheroFieldsFragmentData__asHuman_friends__asHumanBuilder + implements + Builder { + _$GheroFieldsFragmentData__asHuman_friends__asHuman? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + String? _homePlanet; + String? get homePlanet => _$this._homePlanet; + set homePlanet(String? homePlanet) => _$this._homePlanet = homePlanet; + + GheroFieldsFragmentData__asHuman_friends__asHumanBuilder() { + GheroFieldsFragmentData__asHuman_friends__asHuman._initializeBuilder(this); + } + + GheroFieldsFragmentData__asHuman_friends__asHumanBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _name = $v.name; + _homePlanet = $v.homePlanet; + _$v = null; + } + return this; + } + + @override + void replace(GheroFieldsFragmentData__asHuman_friends__asHuman other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GheroFieldsFragmentData__asHuman_friends__asHuman; + } + + @override + void update( + void Function(GheroFieldsFragmentData__asHuman_friends__asHumanBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GheroFieldsFragmentData__asHuman_friends__asHuman build() => _build(); + + _$GheroFieldsFragmentData__asHuman_friends__asHuman _build() { + final _$result = _$v ?? + new _$GheroFieldsFragmentData__asHuman_friends__asHuman._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, + r'GheroFieldsFragmentData__asHuman_friends__asHuman', + 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GheroFieldsFragmentData__asHuman_friends__asHuman', 'id'), + name: BuiltValueNullFieldError.checkNotNull(name, + r'GheroFieldsFragmentData__asHuman_friends__asHuman', 'name'), + homePlanet: homePlanet); + replace(_$result); + return _$result; + } +} + +class _$GheroFieldsFragmentData__asDroid + extends GheroFieldsFragmentData__asDroid { + @override + final String G__typename; + @override + final String id; + @override + final String name; + @override + final String? primaryFunction; + + factory _$GheroFieldsFragmentData__asDroid( + [void Function(GheroFieldsFragmentData__asDroidBuilder)? updates]) => + (new GheroFieldsFragmentData__asDroidBuilder()..update(updates))._build(); + + _$GheroFieldsFragmentData__asDroid._( + {required this.G__typename, + required this.id, + required this.name, + this.primaryFunction}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GheroFieldsFragmentData__asDroid', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + id, r'GheroFieldsFragmentData__asDroid', 'id'); + BuiltValueNullFieldError.checkNotNull( + name, r'GheroFieldsFragmentData__asDroid', 'name'); + } + + @override + GheroFieldsFragmentData__asDroid rebuild( + void Function(GheroFieldsFragmentData__asDroidBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GheroFieldsFragmentData__asDroidBuilder toBuilder() => + new GheroFieldsFragmentData__asDroidBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GheroFieldsFragmentData__asDroid && + G__typename == other.G__typename && + id == other.id && + name == other.name && + primaryFunction == other.primaryFunction; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, primaryFunction.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GheroFieldsFragmentData__asDroid') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('name', name) + ..add('primaryFunction', primaryFunction)) + .toString(); + } +} + +class GheroFieldsFragmentData__asDroidBuilder + implements + Builder { + _$GheroFieldsFragmentData__asDroid? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + String? _primaryFunction; + String? get primaryFunction => _$this._primaryFunction; + set primaryFunction(String? primaryFunction) => + _$this._primaryFunction = primaryFunction; + + GheroFieldsFragmentData__asDroidBuilder() { + GheroFieldsFragmentData__asDroid._initializeBuilder(this); + } + + GheroFieldsFragmentData__asDroidBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _name = $v.name; + _primaryFunction = $v.primaryFunction; + _$v = null; + } + return this; + } + + @override + void replace(GheroFieldsFragmentData__asDroid other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GheroFieldsFragmentData__asDroid; + } + + @override + void update(void Function(GheroFieldsFragmentData__asDroidBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GheroFieldsFragmentData__asDroid build() => _build(); + + _$GheroFieldsFragmentData__asDroid _build() { + final _$result = _$v ?? + new _$GheroFieldsFragmentData__asDroid._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GheroFieldsFragmentData__asDroid', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GheroFieldsFragmentData__asDroid', 'id'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GheroFieldsFragmentData__asDroid', 'name'), + primaryFunction: primaryFunction); + replace(_$result); + return _$result; + } +} + +class _$GhumanFieldsFragmentData extends GhumanFieldsFragmentData { + @override + final String G__typename; + @override + final String? homePlanet; + @override + final BuiltList? friends; + + factory _$GhumanFieldsFragmentData( + [void Function(GhumanFieldsFragmentDataBuilder)? updates]) => + (new GhumanFieldsFragmentDataBuilder()..update(updates))._build(); + + _$GhumanFieldsFragmentData._( + {required this.G__typename, this.homePlanet, this.friends}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GhumanFieldsFragmentData', 'G__typename'); + } + + @override + GhumanFieldsFragmentData rebuild( + void Function(GhumanFieldsFragmentDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GhumanFieldsFragmentDataBuilder toBuilder() => + new GhumanFieldsFragmentDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GhumanFieldsFragmentData && + G__typename == other.G__typename && + homePlanet == other.homePlanet && + friends == other.friends; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, homePlanet.hashCode); + _$hash = $jc(_$hash, friends.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GhumanFieldsFragmentData') + ..add('G__typename', G__typename) + ..add('homePlanet', homePlanet) + ..add('friends', friends)) + .toString(); + } +} + +class GhumanFieldsFragmentDataBuilder + implements + Builder { + _$GhumanFieldsFragmentData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _homePlanet; + String? get homePlanet => _$this._homePlanet; + set homePlanet(String? homePlanet) => _$this._homePlanet = homePlanet; + + ListBuilder? _friends; + ListBuilder get friends => + _$this._friends ??= new ListBuilder(); + set friends(ListBuilder? friends) => + _$this._friends = friends; + + GhumanFieldsFragmentDataBuilder() { + GhumanFieldsFragmentData._initializeBuilder(this); + } + + GhumanFieldsFragmentDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _homePlanet = $v.homePlanet; + _friends = $v.friends?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GhumanFieldsFragmentData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GhumanFieldsFragmentData; + } + + @override + void update(void Function(GhumanFieldsFragmentDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GhumanFieldsFragmentData build() => _build(); + + _$GhumanFieldsFragmentData _build() { + _$GhumanFieldsFragmentData _$result; + try { + _$result = _$v ?? + new _$GhumanFieldsFragmentData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GhumanFieldsFragmentData', 'G__typename'), + homePlanet: homePlanet, + friends: _friends?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'friends'; + _friends?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GhumanFieldsFragmentData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GhumanFieldsFragmentData_friends__base + extends GhumanFieldsFragmentData_friends__base { + @override + final String G__typename; + + factory _$GhumanFieldsFragmentData_friends__base( + [void Function(GhumanFieldsFragmentData_friends__baseBuilder)? + updates]) => + (new GhumanFieldsFragmentData_friends__baseBuilder()..update(updates)) + ._build(); + + _$GhumanFieldsFragmentData_friends__base._({required this.G__typename}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GhumanFieldsFragmentData_friends__base', 'G__typename'); + } + + @override + GhumanFieldsFragmentData_friends__base rebuild( + void Function(GhumanFieldsFragmentData_friends__baseBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GhumanFieldsFragmentData_friends__baseBuilder toBuilder() => + new GhumanFieldsFragmentData_friends__baseBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GhumanFieldsFragmentData_friends__base && + G__typename == other.G__typename; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GhumanFieldsFragmentData_friends__base') + ..add('G__typename', G__typename)) + .toString(); + } +} + +class GhumanFieldsFragmentData_friends__baseBuilder + implements + Builder { + _$GhumanFieldsFragmentData_friends__base? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GhumanFieldsFragmentData_friends__baseBuilder() { + GhumanFieldsFragmentData_friends__base._initializeBuilder(this); + } + + GhumanFieldsFragmentData_friends__baseBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _$v = null; + } + return this; + } + + @override + void replace(GhumanFieldsFragmentData_friends__base other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GhumanFieldsFragmentData_friends__base; + } + + @override + void update( + void Function(GhumanFieldsFragmentData_friends__baseBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GhumanFieldsFragmentData_friends__base build() => _build(); + + _$GhumanFieldsFragmentData_friends__base _build() { + final _$result = _$v ?? + new _$GhumanFieldsFragmentData_friends__base._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GhumanFieldsFragmentData_friends__base', 'G__typename')); + replace(_$result); + return _$result; + } +} + +class _$GhumanFieldsFragmentData_friends__asDroid + extends GhumanFieldsFragmentData_friends__asDroid { + @override + final String G__typename; + @override + final String id; + @override + final String name; + @override + final String? primaryFunction; + + factory _$GhumanFieldsFragmentData_friends__asDroid( + [void Function(GhumanFieldsFragmentData_friends__asDroidBuilder)? + updates]) => + (new GhumanFieldsFragmentData_friends__asDroidBuilder()..update(updates)) + ._build(); + + _$GhumanFieldsFragmentData_friends__asDroid._( + {required this.G__typename, + required this.id, + required this.name, + this.primaryFunction}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GhumanFieldsFragmentData_friends__asDroid', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + id, r'GhumanFieldsFragmentData_friends__asDroid', 'id'); + BuiltValueNullFieldError.checkNotNull( + name, r'GhumanFieldsFragmentData_friends__asDroid', 'name'); + } + + @override + GhumanFieldsFragmentData_friends__asDroid rebuild( + void Function(GhumanFieldsFragmentData_friends__asDroidBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GhumanFieldsFragmentData_friends__asDroidBuilder toBuilder() => + new GhumanFieldsFragmentData_friends__asDroidBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GhumanFieldsFragmentData_friends__asDroid && + G__typename == other.G__typename && + id == other.id && + name == other.name && + primaryFunction == other.primaryFunction; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, primaryFunction.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GhumanFieldsFragmentData_friends__asDroid') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('name', name) + ..add('primaryFunction', primaryFunction)) + .toString(); + } +} + +class GhumanFieldsFragmentData_friends__asDroidBuilder + implements + Builder { + _$GhumanFieldsFragmentData_friends__asDroid? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + String? _primaryFunction; + String? get primaryFunction => _$this._primaryFunction; + set primaryFunction(String? primaryFunction) => + _$this._primaryFunction = primaryFunction; + + GhumanFieldsFragmentData_friends__asDroidBuilder() { + GhumanFieldsFragmentData_friends__asDroid._initializeBuilder(this); + } + + GhumanFieldsFragmentData_friends__asDroidBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _name = $v.name; + _primaryFunction = $v.primaryFunction; + _$v = null; + } + return this; + } + + @override + void replace(GhumanFieldsFragmentData_friends__asDroid other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GhumanFieldsFragmentData_friends__asDroid; + } + + @override + void update( + void Function(GhumanFieldsFragmentData_friends__asDroidBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GhumanFieldsFragmentData_friends__asDroid build() => _build(); + + _$GhumanFieldsFragmentData_friends__asDroid _build() { + final _$result = _$v ?? + new _$GhumanFieldsFragmentData_friends__asDroid._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GhumanFieldsFragmentData_friends__asDroid', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GhumanFieldsFragmentData_friends__asDroid', 'id'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GhumanFieldsFragmentData_friends__asDroid', 'name'), + primaryFunction: primaryFunction); + replace(_$result); + return _$result; + } +} + +class _$GhumanFieldsFragmentData_friends__asHuman + extends GhumanFieldsFragmentData_friends__asHuman { + @override + final String G__typename; + @override + final String id; + @override + final String name; + @override + final String? homePlanet; + + factory _$GhumanFieldsFragmentData_friends__asHuman( + [void Function(GhumanFieldsFragmentData_friends__asHumanBuilder)? + updates]) => + (new GhumanFieldsFragmentData_friends__asHumanBuilder()..update(updates)) + ._build(); + + _$GhumanFieldsFragmentData_friends__asHuman._( + {required this.G__typename, + required this.id, + required this.name, + this.homePlanet}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GhumanFieldsFragmentData_friends__asHuman', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + id, r'GhumanFieldsFragmentData_friends__asHuman', 'id'); + BuiltValueNullFieldError.checkNotNull( + name, r'GhumanFieldsFragmentData_friends__asHuman', 'name'); + } + + @override + GhumanFieldsFragmentData_friends__asHuman rebuild( + void Function(GhumanFieldsFragmentData_friends__asHumanBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GhumanFieldsFragmentData_friends__asHumanBuilder toBuilder() => + new GhumanFieldsFragmentData_friends__asHumanBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GhumanFieldsFragmentData_friends__asHuman && + G__typename == other.G__typename && + id == other.id && + name == other.name && + homePlanet == other.homePlanet; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, homePlanet.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GhumanFieldsFragmentData_friends__asHuman') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('name', name) + ..add('homePlanet', homePlanet)) + .toString(); + } +} + +class GhumanFieldsFragmentData_friends__asHumanBuilder + implements + Builder { + _$GhumanFieldsFragmentData_friends__asHuman? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + String? _homePlanet; + String? get homePlanet => _$this._homePlanet; + set homePlanet(String? homePlanet) => _$this._homePlanet = homePlanet; + + GhumanFieldsFragmentData_friends__asHumanBuilder() { + GhumanFieldsFragmentData_friends__asHuman._initializeBuilder(this); + } + + GhumanFieldsFragmentData_friends__asHumanBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _name = $v.name; + _homePlanet = $v.homePlanet; + _$v = null; + } + return this; + } + + @override + void replace(GhumanFieldsFragmentData_friends__asHuman other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GhumanFieldsFragmentData_friends__asHuman; + } + + @override + void update( + void Function(GhumanFieldsFragmentData_friends__asHumanBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GhumanFieldsFragmentData_friends__asHuman build() => _build(); + + _$GhumanFieldsFragmentData_friends__asHuman _build() { + final _$result = _$v ?? + new _$GhumanFieldsFragmentData_friends__asHuman._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GhumanFieldsFragmentData_friends__asHuman', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GhumanFieldsFragmentData_friends__asHuman', 'id'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GhumanFieldsFragmentData_friends__asHuman', 'name'), + homePlanet: homePlanet); + replace(_$result); + return _$result; + } +} + +class _$GdroidFieldsFragmentData extends GdroidFieldsFragmentData { + @override + final String G__typename; + @override + final String? primaryFunction; + + factory _$GdroidFieldsFragmentData( + [void Function(GdroidFieldsFragmentDataBuilder)? updates]) => + (new GdroidFieldsFragmentDataBuilder()..update(updates))._build(); + + _$GdroidFieldsFragmentData._( + {required this.G__typename, this.primaryFunction}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GdroidFieldsFragmentData', 'G__typename'); + } + + @override + GdroidFieldsFragmentData rebuild( + void Function(GdroidFieldsFragmentDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GdroidFieldsFragmentDataBuilder toBuilder() => + new GdroidFieldsFragmentDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GdroidFieldsFragmentData && + G__typename == other.G__typename && + primaryFunction == other.primaryFunction; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, primaryFunction.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GdroidFieldsFragmentData') + ..add('G__typename', G__typename) + ..add('primaryFunction', primaryFunction)) + .toString(); + } +} + +class GdroidFieldsFragmentDataBuilder + implements + Builder { + _$GdroidFieldsFragmentData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _primaryFunction; + String? get primaryFunction => _$this._primaryFunction; + set primaryFunction(String? primaryFunction) => + _$this._primaryFunction = primaryFunction; + + GdroidFieldsFragmentDataBuilder() { + GdroidFieldsFragmentData._initializeBuilder(this); + } + + GdroidFieldsFragmentDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _primaryFunction = $v.primaryFunction; + _$v = null; + } + return this; + } + + @override + void replace(GdroidFieldsFragmentData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GdroidFieldsFragmentData; + } + + @override + void update(void Function(GdroidFieldsFragmentDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GdroidFieldsFragmentData build() => _build(); + + _$GdroidFieldsFragmentData _build() { + final _$result = _$v ?? + new _$GdroidFieldsFragmentData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GdroidFieldsFragmentData', 'G__typename'), + primaryFunction: primaryFunction); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.req.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.req.gql.dart new file mode 100644 index 00000000..d99721e8 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.req.gql.dart @@ -0,0 +1,51 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_interface_subtyped_fragments.ast.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart' + as _i3; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'hero_with_interface_subtyped_fragments.req.gql.g.dart'; + +abstract class GHeroWithInterfaceSubTypedFragments + implements + Built { + GHeroWithInterfaceSubTypedFragments._(); + + factory GHeroWithInterfaceSubTypedFragments( + [Function(GHeroWithInterfaceSubTypedFragmentsBuilder b) updates]) = + _$GHeroWithInterfaceSubTypedFragments; + + static void _initializeBuilder( + GHeroWithInterfaceSubTypedFragmentsBuilder b) => + b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'HeroWithInterfaceSubTypedFragments', + ); + + _i3.GHeroWithInterfaceSubTypedFragmentsVars get vars; + _i1.Operation get operation; + static Serializer get serializer => + _$gHeroWithInterfaceSubTypedFragmentsSerializer; + + Map toJson() => (_i4.serializers.serializeWith( + GHeroWithInterfaceSubTypedFragments.serializer, + this, + ) as Map); + + static GHeroWithInterfaceSubTypedFragments? fromJson( + Map json) => + _i4.serializers.deserializeWith( + GHeroWithInterfaceSubTypedFragments.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.req.gql.g.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.req.gql.g.dart new file mode 100644 index 00000000..39a20488 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.req.gql.g.dart @@ -0,0 +1,197 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'hero_with_interface_subtyped_fragments.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer + _$gHeroWithInterfaceSubTypedFragmentsSerializer = + new _$GHeroWithInterfaceSubTypedFragmentsSerializer(); + +class _$GHeroWithInterfaceSubTypedFragmentsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroWithInterfaceSubTypedFragments, + _$GHeroWithInterfaceSubTypedFragments + ]; + @override + final String wireName = 'GHeroWithInterfaceSubTypedFragments'; + + @override + Iterable serialize( + Serializers serializers, GHeroWithInterfaceSubTypedFragments object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: + const FullType(_i3.GHeroWithInterfaceSubTypedFragmentsVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GHeroWithInterfaceSubTypedFragments deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroWithInterfaceSubTypedFragmentsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'vars': + result.vars.replace(serializers.deserialize(value, + specifiedType: const FullType( + _i3.GHeroWithInterfaceSubTypedFragmentsVars))! + as _i3.GHeroWithInterfaceSubTypedFragmentsVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GHeroWithInterfaceSubTypedFragments + extends GHeroWithInterfaceSubTypedFragments { + @override + final _i3.GHeroWithInterfaceSubTypedFragmentsVars vars; + @override + final _i1.Operation operation; + + factory _$GHeroWithInterfaceSubTypedFragments( + [void Function(GHeroWithInterfaceSubTypedFragmentsBuilder)? + updates]) => + (new GHeroWithInterfaceSubTypedFragmentsBuilder()..update(updates)) + ._build(); + + _$GHeroWithInterfaceSubTypedFragments._( + {required this.vars, required this.operation}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + vars, r'GHeroWithInterfaceSubTypedFragments', 'vars'); + BuiltValueNullFieldError.checkNotNull( + operation, r'GHeroWithInterfaceSubTypedFragments', 'operation'); + } + + @override + GHeroWithInterfaceSubTypedFragments rebuild( + void Function(GHeroWithInterfaceSubTypedFragmentsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWithInterfaceSubTypedFragmentsBuilder toBuilder() => + new GHeroWithInterfaceSubTypedFragmentsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWithInterfaceSubTypedFragments && + vars == other.vars && + operation == other.operation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroWithInterfaceSubTypedFragments') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GHeroWithInterfaceSubTypedFragmentsBuilder + implements + Builder { + _$GHeroWithInterfaceSubTypedFragments? _$v; + + _i3.GHeroWithInterfaceSubTypedFragmentsVarsBuilder? _vars; + _i3.GHeroWithInterfaceSubTypedFragmentsVarsBuilder get vars => + _$this._vars ??= new _i3.GHeroWithInterfaceSubTypedFragmentsVarsBuilder(); + set vars(_i3.GHeroWithInterfaceSubTypedFragmentsVarsBuilder? vars) => + _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GHeroWithInterfaceSubTypedFragmentsBuilder() { + GHeroWithInterfaceSubTypedFragments._initializeBuilder(this); + } + + GHeroWithInterfaceSubTypedFragmentsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GHeroWithInterfaceSubTypedFragments other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWithInterfaceSubTypedFragments; + } + + @override + void update( + void Function(GHeroWithInterfaceSubTypedFragmentsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroWithInterfaceSubTypedFragments build() => _build(); + + _$GHeroWithInterfaceSubTypedFragments _build() { + _$GHeroWithInterfaceSubTypedFragments _$result; + try { + _$result = _$v ?? + new _$GHeroWithInterfaceSubTypedFragments._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull(operation, + r'GHeroWithInterfaceSubTypedFragments', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroWithInterfaceSubTypedFragments', + _$failedField, + e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart new file mode 100644 index 00000000..085117ba --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart @@ -0,0 +1,236 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart' + as _i1; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i2; + +part 'hero_with_interface_subtyped_fragments.var.gql.g.dart'; + +abstract class GHeroWithInterfaceSubTypedFragmentsVars + implements + Built { + GHeroWithInterfaceSubTypedFragmentsVars._(); + + factory GHeroWithInterfaceSubTypedFragmentsVars( + [Function(GHeroWithInterfaceSubTypedFragmentsVarsBuilder b) + updates]) = _$GHeroWithInterfaceSubTypedFragmentsVars; + + _i1.GEpisode get episode; + Map toJson() => (_i2.serializers.serializeWith( + GHeroWithInterfaceSubTypedFragmentsVars.serializer, + this, + ) as Map); + + static GHeroWithInterfaceSubTypedFragmentsVars? fromJson( + Map json) => + _i2.serializers.deserializeWith( + GHeroWithInterfaceSubTypedFragmentsVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GHeroWithInterfaceSubTypedFragmentsVarsSerializer(); +} + +abstract class GheroFieldsFragmentVars + implements Built { + GheroFieldsFragmentVars._(); + + factory GheroFieldsFragmentVars( + [Function(GheroFieldsFragmentVarsBuilder b) updates]) = + _$GheroFieldsFragmentVars; + + Map toJson() => (_i2.serializers.serializeWith( + GheroFieldsFragmentVars.serializer, + this, + ) as Map); + + static GheroFieldsFragmentVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GheroFieldsFragmentVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GheroFieldsFragmentVarsSerializer(); +} + +abstract class GhumanFieldsFragmentVars + implements + Built { + GhumanFieldsFragmentVars._(); + + factory GhumanFieldsFragmentVars( + [Function(GhumanFieldsFragmentVarsBuilder b) updates]) = + _$GhumanFieldsFragmentVars; + + Map toJson() => (_i2.serializers.serializeWith( + GhumanFieldsFragmentVars.serializer, + this, + ) as Map); + + static GhumanFieldsFragmentVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GhumanFieldsFragmentVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GhumanFieldsFragmentVarsSerializer(); +} + +abstract class GdroidFieldsFragmentVars + implements + Built { + GdroidFieldsFragmentVars._(); + + factory GdroidFieldsFragmentVars( + [Function(GdroidFieldsFragmentVarsBuilder b) updates]) = + _$GdroidFieldsFragmentVars; + + Map toJson() => (_i2.serializers.serializeWith( + GdroidFieldsFragmentVars.serializer, + this, + ) as Map); + + static GdroidFieldsFragmentVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GdroidFieldsFragmentVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GdroidFieldsFragmentVarsSerializer(); +} + +class GHeroWithInterfaceSubTypedFragmentsVarsSerializer + extends StructuredSerializer { + final String wireName = 'GHeroWithInterfaceSubTypedFragmentsVars'; + + final Iterable types = const [ + GHeroWithInterfaceSubTypedFragmentsVars, + _$GHeroWithInterfaceSubTypedFragmentsVars + ]; + + Iterable serialize( + Serializers serializers, + GHeroWithInterfaceSubTypedFragmentsVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('episode'); + result.add(serializers.serialize(object.episode, + specifiedType: const FullType(_i1.GEpisode))); + return result; + } + + GHeroWithInterfaceSubTypedFragmentsVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GHeroWithInterfaceSubTypedFragmentsVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'episode': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; + builder.episode = fieldValue; + break; + } + } + return builder.build(); + } +} + +class GheroFieldsFragmentVarsSerializer + extends StructuredSerializer { + final String wireName = 'GheroFieldsFragmentVars'; + + final Iterable types = const [ + GheroFieldsFragmentVars, + _$GheroFieldsFragmentVars + ]; + + Iterable serialize( + Serializers serializers, + GheroFieldsFragmentVars object, { + FullType specifiedType = FullType.unspecified, + }) { + return const []; + } + + GheroFieldsFragmentVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + return GheroFieldsFragmentVars(); + } +} + +class GhumanFieldsFragmentVarsSerializer + extends StructuredSerializer { + final String wireName = 'GhumanFieldsFragmentVars'; + + final Iterable types = const [ + GhumanFieldsFragmentVars, + _$GhumanFieldsFragmentVars + ]; + + Iterable serialize( + Serializers serializers, + GhumanFieldsFragmentVars object, { + FullType specifiedType = FullType.unspecified, + }) { + return const []; + } + + GhumanFieldsFragmentVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + return GhumanFieldsFragmentVars(); + } +} + +class GdroidFieldsFragmentVarsSerializer + extends StructuredSerializer { + final String wireName = 'GdroidFieldsFragmentVars'; + + final Iterable types = const [ + GdroidFieldsFragmentVars, + _$GdroidFieldsFragmentVars + ]; + + Iterable serialize( + Serializers serializers, + GdroidFieldsFragmentVars object, { + FullType specifiedType = FullType.unspecified, + }) { + return const []; + } + + GdroidFieldsFragmentVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + return GdroidFieldsFragmentVars(); + } +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.g.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.g.dart new file mode 100644 index 00000000..0689f5b4 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.g.dart @@ -0,0 +1,289 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'hero_with_interface_subtyped_fragments.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$GHeroWithInterfaceSubTypedFragmentsVars + extends GHeroWithInterfaceSubTypedFragmentsVars { + @override + final _i1.GEpisode episode; + + factory _$GHeroWithInterfaceSubTypedFragmentsVars( + [void Function(GHeroWithInterfaceSubTypedFragmentsVarsBuilder)? + updates]) => + (new GHeroWithInterfaceSubTypedFragmentsVarsBuilder()..update(updates)) + ._build(); + + _$GHeroWithInterfaceSubTypedFragmentsVars._({required this.episode}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + episode, r'GHeroWithInterfaceSubTypedFragmentsVars', 'episode'); + } + + @override + GHeroWithInterfaceSubTypedFragmentsVars rebuild( + void Function(GHeroWithInterfaceSubTypedFragmentsVarsBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWithInterfaceSubTypedFragmentsVarsBuilder toBuilder() => + new GHeroWithInterfaceSubTypedFragmentsVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWithInterfaceSubTypedFragmentsVars && + episode == other.episode; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, episode.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GHeroWithInterfaceSubTypedFragmentsVars') + ..add('episode', episode)) + .toString(); + } +} + +class GHeroWithInterfaceSubTypedFragmentsVarsBuilder + implements + Builder { + _$GHeroWithInterfaceSubTypedFragmentsVars? _$v; + + _i1.GEpisode? _episode; + _i1.GEpisode? get episode => _$this._episode; + set episode(_i1.GEpisode? episode) => _$this._episode = episode; + + GHeroWithInterfaceSubTypedFragmentsVarsBuilder(); + + GHeroWithInterfaceSubTypedFragmentsVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _episode = $v.episode; + _$v = null; + } + return this; + } + + @override + void replace(GHeroWithInterfaceSubTypedFragmentsVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWithInterfaceSubTypedFragmentsVars; + } + + @override + void update( + void Function(GHeroWithInterfaceSubTypedFragmentsVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroWithInterfaceSubTypedFragmentsVars build() => _build(); + + _$GHeroWithInterfaceSubTypedFragmentsVars _build() { + final _$result = _$v ?? + new _$GHeroWithInterfaceSubTypedFragmentsVars._( + episode: BuiltValueNullFieldError.checkNotNull(episode, + r'GHeroWithInterfaceSubTypedFragmentsVars', 'episode')); + replace(_$result); + return _$result; + } +} + +class _$GheroFieldsFragmentVars extends GheroFieldsFragmentVars { + factory _$GheroFieldsFragmentVars( + [void Function(GheroFieldsFragmentVarsBuilder)? updates]) => + (new GheroFieldsFragmentVarsBuilder()..update(updates))._build(); + + _$GheroFieldsFragmentVars._() : super._(); + + @override + GheroFieldsFragmentVars rebuild( + void Function(GheroFieldsFragmentVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GheroFieldsFragmentVarsBuilder toBuilder() => + new GheroFieldsFragmentVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GheroFieldsFragmentVars; + } + + @override + int get hashCode { + return 964700462; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GheroFieldsFragmentVars').toString(); + } +} + +class GheroFieldsFragmentVarsBuilder + implements + Builder { + _$GheroFieldsFragmentVars? _$v; + + GheroFieldsFragmentVarsBuilder(); + + @override + void replace(GheroFieldsFragmentVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GheroFieldsFragmentVars; + } + + @override + void update(void Function(GheroFieldsFragmentVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GheroFieldsFragmentVars build() => _build(); + + _$GheroFieldsFragmentVars _build() { + final _$result = _$v ?? new _$GheroFieldsFragmentVars._(); + replace(_$result); + return _$result; + } +} + +class _$GhumanFieldsFragmentVars extends GhumanFieldsFragmentVars { + factory _$GhumanFieldsFragmentVars( + [void Function(GhumanFieldsFragmentVarsBuilder)? updates]) => + (new GhumanFieldsFragmentVarsBuilder()..update(updates))._build(); + + _$GhumanFieldsFragmentVars._() : super._(); + + @override + GhumanFieldsFragmentVars rebuild( + void Function(GhumanFieldsFragmentVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GhumanFieldsFragmentVarsBuilder toBuilder() => + new GhumanFieldsFragmentVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GhumanFieldsFragmentVars; + } + + @override + int get hashCode { + return 101332054; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GhumanFieldsFragmentVars').toString(); + } +} + +class GhumanFieldsFragmentVarsBuilder + implements + Builder { + _$GhumanFieldsFragmentVars? _$v; + + GhumanFieldsFragmentVarsBuilder(); + + @override + void replace(GhumanFieldsFragmentVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GhumanFieldsFragmentVars; + } + + @override + void update(void Function(GhumanFieldsFragmentVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GhumanFieldsFragmentVars build() => _build(); + + _$GhumanFieldsFragmentVars _build() { + final _$result = _$v ?? new _$GhumanFieldsFragmentVars._(); + replace(_$result); + return _$result; + } +} + +class _$GdroidFieldsFragmentVars extends GdroidFieldsFragmentVars { + factory _$GdroidFieldsFragmentVars( + [void Function(GdroidFieldsFragmentVarsBuilder)? updates]) => + (new GdroidFieldsFragmentVarsBuilder()..update(updates))._build(); + + _$GdroidFieldsFragmentVars._() : super._(); + + @override + GdroidFieldsFragmentVars rebuild( + void Function(GdroidFieldsFragmentVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GdroidFieldsFragmentVarsBuilder toBuilder() => + new GdroidFieldsFragmentVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GdroidFieldsFragmentVars; + } + + @override + int get hashCode { + return 244025792; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GdroidFieldsFragmentVars').toString(); + } +} + +class GdroidFieldsFragmentVarsBuilder + implements + Builder { + _$GdroidFieldsFragmentVars? _$v; + + GdroidFieldsFragmentVarsBuilder(); + + @override + void replace(GdroidFieldsFragmentVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GdroidFieldsFragmentVars; + } + + @override + void update(void Function(GdroidFieldsFragmentVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GdroidFieldsFragmentVars build() => _build(); + + _$GdroidFieldsFragmentVars _build() { + final _$result = _$v ?? new _$GdroidFieldsFragmentVars._(); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.ast.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.ast.gql.dart new file mode 100644 index 00000000..d519c9f7 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.ast.gql.dart @@ -0,0 +1,86 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const heroName = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'heroName'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), +); +const heroId = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'heroId'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), +); +const HeroWith2Fragments = _i1.OperationDefinitionNode( + type: _i1.OperationType.query, + name: _i1.NameNode(value: 'HeroWith2Fragments'), + variableDefinitions: [ + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'first')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: false, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'hero'), + alias: null, + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'episode'), + value: _i1.EnumValueNode(name: _i1.NameNode(value: 'JEDI')), + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'heroName'), + directives: [], + ), + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'heroId'), + directives: [], + ), + ]), + ) + ]), +); +const document = _i1.DocumentNode(definitions: [ + heroName, + heroId, + HeroWith2Fragments, +]); diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.data.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.data.gql.dart new file mode 100644 index 00000000..d4a49c2f --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.data.gql.dart @@ -0,0 +1,148 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'multiple_fragments.data.gql.g.dart'; + +abstract class GHeroWith2FragmentsData + implements Built { + GHeroWith2FragmentsData._(); + + factory GHeroWith2FragmentsData( + [Function(GHeroWith2FragmentsDataBuilder b) updates]) = + _$GHeroWith2FragmentsData; + + static void _initializeBuilder(GHeroWith2FragmentsDataBuilder b) => + b..G__typename = 'Query'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + GHeroWith2FragmentsData_hero? get hero; + static Serializer get serializer => + _$gHeroWith2FragmentsDataSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GHeroWith2FragmentsData.serializer, + this, + ) as Map); + + static GHeroWith2FragmentsData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GHeroWith2FragmentsData.serializer, + json, + ); +} + +abstract class GHeroWith2FragmentsData_hero + implements + Built, + GheroName, + GheroId { + GHeroWith2FragmentsData_hero._(); + + factory GHeroWith2FragmentsData_hero( + [Function(GHeroWith2FragmentsData_heroBuilder b) updates]) = + _$GHeroWith2FragmentsData_hero; + + static void _initializeBuilder(GHeroWith2FragmentsData_heroBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get name; + @override + String get id; + static Serializer get serializer => + _$gHeroWith2FragmentsDataHeroSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GHeroWith2FragmentsData_hero.serializer, + this, + ) as Map); + + static GHeroWith2FragmentsData_hero? fromJson(Map json) => + _i1.serializers.deserializeWith( + GHeroWith2FragmentsData_hero.serializer, + json, + ); +} + +abstract class GheroName { + String get G__typename; + String get name; + Map toJson(); +} + +abstract class GheroNameData + implements Built, GheroName { + GheroNameData._(); + + factory GheroNameData([Function(GheroNameDataBuilder b) updates]) = + _$GheroNameData; + + static void _initializeBuilder(GheroNameDataBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get name; + static Serializer get serializer => _$gheroNameDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GheroNameData.serializer, + this, + ) as Map); + + static GheroNameData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GheroNameData.serializer, + json, + ); +} + +abstract class GheroId { + String get G__typename; + String get id; + Map toJson(); +} + +abstract class GheroIdData + implements Built, GheroId { + GheroIdData._(); + + factory GheroIdData([Function(GheroIdDataBuilder b) updates]) = _$GheroIdData; + + static void _initializeBuilder(GheroIdDataBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get id; + static Serializer get serializer => _$gheroIdDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GheroIdData.serializer, + this, + ) as Map); + + static GheroIdData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GheroIdData.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.data.gql.g.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.data.gql.g.dart new file mode 100644 index 00000000..a4f296dc --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.data.gql.g.dart @@ -0,0 +1,666 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'multiple_fragments.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gHeroWith2FragmentsDataSerializer = + new _$GHeroWith2FragmentsDataSerializer(); +Serializer + _$gHeroWith2FragmentsDataHeroSerializer = + new _$GHeroWith2FragmentsData_heroSerializer(); +Serializer _$gheroNameDataSerializer = + new _$GheroNameDataSerializer(); +Serializer _$gheroIdDataSerializer = new _$GheroIdDataSerializer(); + +class _$GHeroWith2FragmentsDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroWith2FragmentsData, + _$GHeroWith2FragmentsData + ]; + @override + final String wireName = 'GHeroWith2FragmentsData'; + + @override + Iterable serialize( + Serializers serializers, GHeroWith2FragmentsData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.hero; + if (value != null) { + result + ..add('hero') + ..add(serializers.serialize(value, + specifiedType: const FullType(GHeroWith2FragmentsData_hero))); + } + return result; + } + + @override + GHeroWith2FragmentsData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroWith2FragmentsDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'hero': + result.hero.replace(serializers.deserialize(value, + specifiedType: const FullType(GHeroWith2FragmentsData_hero))! + as GHeroWith2FragmentsData_hero); + break; + } + } + + return result.build(); + } +} + +class _$GHeroWith2FragmentsData_heroSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroWith2FragmentsData_hero, + _$GHeroWith2FragmentsData_hero + ]; + @override + final String wireName = 'GHeroWith2FragmentsData_hero'; + + @override + Iterable serialize( + Serializers serializers, GHeroWith2FragmentsData_hero object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GHeroWith2FragmentsData_hero deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroWith2FragmentsData_heroBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GheroNameDataSerializer implements StructuredSerializer { + @override + final Iterable types = const [GheroNameData, _$GheroNameData]; + @override + final String wireName = 'GheroNameData'; + + @override + Iterable serialize(Serializers serializers, GheroNameData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GheroNameData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GheroNameDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GheroIdDataSerializer implements StructuredSerializer { + @override + final Iterable types = const [GheroIdData, _$GheroIdData]; + @override + final String wireName = 'GheroIdData'; + + @override + Iterable serialize(Serializers serializers, GheroIdData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GheroIdData deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GheroIdDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GHeroWith2FragmentsData extends GHeroWith2FragmentsData { + @override + final String G__typename; + @override + final GHeroWith2FragmentsData_hero? hero; + + factory _$GHeroWith2FragmentsData( + [void Function(GHeroWith2FragmentsDataBuilder)? updates]) => + (new GHeroWith2FragmentsDataBuilder()..update(updates))._build(); + + _$GHeroWith2FragmentsData._({required this.G__typename, this.hero}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroWith2FragmentsData', 'G__typename'); + } + + @override + GHeroWith2FragmentsData rebuild( + void Function(GHeroWith2FragmentsDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWith2FragmentsDataBuilder toBuilder() => + new GHeroWith2FragmentsDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWith2FragmentsData && + G__typename == other.G__typename && + hero == other.hero; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, hero.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroWith2FragmentsData') + ..add('G__typename', G__typename) + ..add('hero', hero)) + .toString(); + } +} + +class GHeroWith2FragmentsDataBuilder + implements + Builder { + _$GHeroWith2FragmentsData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GHeroWith2FragmentsData_heroBuilder? _hero; + GHeroWith2FragmentsData_heroBuilder get hero => + _$this._hero ??= new GHeroWith2FragmentsData_heroBuilder(); + set hero(GHeroWith2FragmentsData_heroBuilder? hero) => _$this._hero = hero; + + GHeroWith2FragmentsDataBuilder() { + GHeroWith2FragmentsData._initializeBuilder(this); + } + + GHeroWith2FragmentsDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _hero = $v.hero?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GHeroWith2FragmentsData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWith2FragmentsData; + } + + @override + void update(void Function(GHeroWith2FragmentsDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroWith2FragmentsData build() => _build(); + + _$GHeroWith2FragmentsData _build() { + _$GHeroWith2FragmentsData _$result; + try { + _$result = _$v ?? + new _$GHeroWith2FragmentsData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroWith2FragmentsData', 'G__typename'), + hero: _hero?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'hero'; + _hero?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroWith2FragmentsData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GHeroWith2FragmentsData_hero extends GHeroWith2FragmentsData_hero { + @override + final String G__typename; + @override + final String name; + @override + final String id; + + factory _$GHeroWith2FragmentsData_hero( + [void Function(GHeroWith2FragmentsData_heroBuilder)? updates]) => + (new GHeroWith2FragmentsData_heroBuilder()..update(updates))._build(); + + _$GHeroWith2FragmentsData_hero._( + {required this.G__typename, required this.name, required this.id}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroWith2FragmentsData_hero', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + name, r'GHeroWith2FragmentsData_hero', 'name'); + BuiltValueNullFieldError.checkNotNull( + id, r'GHeroWith2FragmentsData_hero', 'id'); + } + + @override + GHeroWith2FragmentsData_hero rebuild( + void Function(GHeroWith2FragmentsData_heroBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWith2FragmentsData_heroBuilder toBuilder() => + new GHeroWith2FragmentsData_heroBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWith2FragmentsData_hero && + G__typename == other.G__typename && + name == other.name && + id == other.id; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroWith2FragmentsData_hero') + ..add('G__typename', G__typename) + ..add('name', name) + ..add('id', id)) + .toString(); + } +} + +class GHeroWith2FragmentsData_heroBuilder + implements + Builder { + _$GHeroWith2FragmentsData_hero? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + GHeroWith2FragmentsData_heroBuilder() { + GHeroWith2FragmentsData_hero._initializeBuilder(this); + } + + GHeroWith2FragmentsData_heroBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _name = $v.name; + _id = $v.id; + _$v = null; + } + return this; + } + + @override + void replace(GHeroWith2FragmentsData_hero other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWith2FragmentsData_hero; + } + + @override + void update(void Function(GHeroWith2FragmentsData_heroBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroWith2FragmentsData_hero build() => _build(); + + _$GHeroWith2FragmentsData_hero _build() { + final _$result = _$v ?? + new _$GHeroWith2FragmentsData_hero._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroWith2FragmentsData_hero', 'G__typename'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GHeroWith2FragmentsData_hero', 'name'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GHeroWith2FragmentsData_hero', 'id')); + replace(_$result); + return _$result; + } +} + +class _$GheroNameData extends GheroNameData { + @override + final String G__typename; + @override + final String name; + + factory _$GheroNameData([void Function(GheroNameDataBuilder)? updates]) => + (new GheroNameDataBuilder()..update(updates))._build(); + + _$GheroNameData._({required this.G__typename, required this.name}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GheroNameData', 'G__typename'); + BuiltValueNullFieldError.checkNotNull(name, r'GheroNameData', 'name'); + } + + @override + GheroNameData rebuild(void Function(GheroNameDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GheroNameDataBuilder toBuilder() => new GheroNameDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GheroNameData && + G__typename == other.G__typename && + name == other.name; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GheroNameData') + ..add('G__typename', G__typename) + ..add('name', name)) + .toString(); + } +} + +class GheroNameDataBuilder + implements Builder { + _$GheroNameData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + GheroNameDataBuilder() { + GheroNameData._initializeBuilder(this); + } + + GheroNameDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _name = $v.name; + _$v = null; + } + return this; + } + + @override + void replace(GheroNameData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GheroNameData; + } + + @override + void update(void Function(GheroNameDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GheroNameData build() => _build(); + + _$GheroNameData _build() { + final _$result = _$v ?? + new _$GheroNameData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GheroNameData', 'G__typename'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GheroNameData', 'name')); + replace(_$result); + return _$result; + } +} + +class _$GheroIdData extends GheroIdData { + @override + final String G__typename; + @override + final String id; + + factory _$GheroIdData([void Function(GheroIdDataBuilder)? updates]) => + (new GheroIdDataBuilder()..update(updates))._build(); + + _$GheroIdData._({required this.G__typename, required this.id}) : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GheroIdData', 'G__typename'); + BuiltValueNullFieldError.checkNotNull(id, r'GheroIdData', 'id'); + } + + @override + GheroIdData rebuild(void Function(GheroIdDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GheroIdDataBuilder toBuilder() => new GheroIdDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GheroIdData && + G__typename == other.G__typename && + id == other.id; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GheroIdData') + ..add('G__typename', G__typename) + ..add('id', id)) + .toString(); + } +} + +class GheroIdDataBuilder implements Builder { + _$GheroIdData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + GheroIdDataBuilder() { + GheroIdData._initializeBuilder(this); + } + + GheroIdDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _$v = null; + } + return this; + } + + @override + void replace(GheroIdData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GheroIdData; + } + + @override + void update(void Function(GheroIdDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GheroIdData build() => _build(); + + _$GheroIdData _build() { + final _$result = _$v ?? + new _$GheroIdData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GheroIdData', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GheroIdData', 'id')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.req.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.req.gql.dart new file mode 100644 index 00000000..a6c9f01f --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.req.gql.dart @@ -0,0 +1,45 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/fragments/__generated__/multiple_fragments.ast.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/fragments/__generated__/multiple_fragments.var.gql.dart' + as _i3; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'multiple_fragments.req.gql.g.dart'; + +abstract class GHeroWith2Fragments + implements Built { + GHeroWith2Fragments._(); + + factory GHeroWith2Fragments( + [Function(GHeroWith2FragmentsBuilder b) updates]) = _$GHeroWith2Fragments; + + static void _initializeBuilder(GHeroWith2FragmentsBuilder b) => b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'HeroWith2Fragments', + ); + + _i3.GHeroWith2FragmentsVars get vars; + _i1.Operation get operation; + static Serializer get serializer => + _$gHeroWith2FragmentsSerializer; + + Map toJson() => (_i4.serializers.serializeWith( + GHeroWith2Fragments.serializer, + this, + ) as Map); + + static GHeroWith2Fragments? fromJson(Map json) => + _i4.serializers.deserializeWith( + GHeroWith2Fragments.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.req.gql.g.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.req.gql.g.dart new file mode 100644 index 00000000..904f74bf --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.req.gql.g.dart @@ -0,0 +1,183 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'multiple_fragments.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gHeroWith2FragmentsSerializer = + new _$GHeroWith2FragmentsSerializer(); + +class _$GHeroWith2FragmentsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroWith2Fragments, + _$GHeroWith2Fragments + ]; + @override + final String wireName = 'GHeroWith2Fragments'; + + @override + Iterable serialize( + Serializers serializers, GHeroWith2Fragments object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: const FullType(_i3.GHeroWith2FragmentsVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GHeroWith2Fragments deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroWith2FragmentsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'vars': + result.vars.replace(serializers.deserialize(value, + specifiedType: const FullType(_i3.GHeroWith2FragmentsVars))! + as _i3.GHeroWith2FragmentsVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GHeroWith2Fragments extends GHeroWith2Fragments { + @override + final _i3.GHeroWith2FragmentsVars vars; + @override + final _i1.Operation operation; + + factory _$GHeroWith2Fragments( + [void Function(GHeroWith2FragmentsBuilder)? updates]) => + (new GHeroWith2FragmentsBuilder()..update(updates))._build(); + + _$GHeroWith2Fragments._({required this.vars, required this.operation}) + : super._() { + BuiltValueNullFieldError.checkNotNull(vars, r'GHeroWith2Fragments', 'vars'); + BuiltValueNullFieldError.checkNotNull( + operation, r'GHeroWith2Fragments', 'operation'); + } + + @override + GHeroWith2Fragments rebuild( + void Function(GHeroWith2FragmentsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWith2FragmentsBuilder toBuilder() => + new GHeroWith2FragmentsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWith2Fragments && + vars == other.vars && + operation == other.operation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroWith2Fragments') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GHeroWith2FragmentsBuilder + implements Builder { + _$GHeroWith2Fragments? _$v; + + _i3.GHeroWith2FragmentsVarsBuilder? _vars; + _i3.GHeroWith2FragmentsVarsBuilder get vars => + _$this._vars ??= new _i3.GHeroWith2FragmentsVarsBuilder(); + set vars(_i3.GHeroWith2FragmentsVarsBuilder? vars) => _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GHeroWith2FragmentsBuilder() { + GHeroWith2Fragments._initializeBuilder(this); + } + + GHeroWith2FragmentsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GHeroWith2Fragments other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWith2Fragments; + } + + @override + void update(void Function(GHeroWith2FragmentsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroWith2Fragments build() => _build(); + + _$GHeroWith2Fragments _build() { + _$GHeroWith2Fragments _$result; + try { + _$result = _$v ?? + new _$GHeroWith2Fragments._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull( + operation, r'GHeroWith2Fragments', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroWith2Fragments', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.dart new file mode 100644 index 00000000..4e61b86a --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.dart @@ -0,0 +1,172 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i2; +import 'package:gql_exec/value.dart' as _i1; + +part 'multiple_fragments.var.gql.g.dart'; + +abstract class GHeroWith2FragmentsVars + implements Built { + GHeroWith2FragmentsVars._(); + + factory GHeroWith2FragmentsVars( + [Function(GHeroWith2FragmentsVarsBuilder b) updates]) = + _$GHeroWith2FragmentsVars; + + static void _initializeBuilder(GHeroWith2FragmentsVarsBuilder b) => + b..first = const _i1.AbsentValue(); + + _i1.Value? get first; + Map toJson() => (_i2.serializers.serializeWith( + GHeroWith2FragmentsVars.serializer, + this, + ) as Map); + + static GHeroWith2FragmentsVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GHeroWith2FragmentsVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GHeroWith2FragmentsVarsSerializer(); +} + +abstract class GheroNameVars + implements Built { + GheroNameVars._(); + + factory GheroNameVars([Function(GheroNameVarsBuilder b) updates]) = + _$GheroNameVars; + + Map toJson() => (_i2.serializers.serializeWith( + GheroNameVars.serializer, + this, + ) as Map); + + static GheroNameVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GheroNameVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => GheroNameVarsSerializer(); +} + +abstract class GheroIdVars implements Built { + GheroIdVars._(); + + factory GheroIdVars([Function(GheroIdVarsBuilder b) updates]) = _$GheroIdVars; + + Map toJson() => (_i2.serializers.serializeWith( + GheroIdVars.serializer, + this, + ) as Map); + + static GheroIdVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GheroIdVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => GheroIdVarsSerializer(); +} + +class GHeroWith2FragmentsVarsSerializer + extends StructuredSerializer { + final String wireName = 'GHeroWith2FragmentsVars'; + + final Iterable types = const [ + GHeroWith2FragmentsVars, + _$GHeroWith2FragmentsVars + ]; + + Iterable serialize( + Serializers serializers, + GHeroWith2FragmentsVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + final _$firstvalue = object.first; + if (_$firstvalue case _i1.PresentValue(value: final _$value)) { + result.add('first'); + result.add( + serializers.serialize(_$value, specifiedType: const FullType(int))); + } + return result; + } + + GHeroWith2FragmentsVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GHeroWith2FragmentsVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'first': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + builder.first = _i1.PresentValue(fieldValue); + break; + } + } + return builder.build(); + } +} + +class GheroNameVarsSerializer extends StructuredSerializer { + final String wireName = 'GheroNameVars'; + + final Iterable types = const [GheroNameVars, _$GheroNameVars]; + + Iterable serialize( + Serializers serializers, + GheroNameVars object, { + FullType specifiedType = FullType.unspecified, + }) { + return const []; + } + + GheroNameVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + return GheroNameVars(); + } +} + +class GheroIdVarsSerializer extends StructuredSerializer { + final String wireName = 'GheroIdVars'; + + final Iterable types = const [GheroIdVars, _$GheroIdVars]; + + Iterable serialize( + Serializers serializers, + GheroIdVars object, { + FullType specifiedType = FullType.unspecified, + }) { + return const []; + } + + GheroIdVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + return GheroIdVars(); + } +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.g.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.g.dart new file mode 100644 index 00000000..24362a11 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.g.dart @@ -0,0 +1,206 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'multiple_fragments.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$GHeroWith2FragmentsVars extends GHeroWith2FragmentsVars { + @override + final _i1.Value? first; + + factory _$GHeroWith2FragmentsVars( + [void Function(GHeroWith2FragmentsVarsBuilder)? updates]) => + (new GHeroWith2FragmentsVarsBuilder()..update(updates))._build(); + + _$GHeroWith2FragmentsVars._({this.first}) : super._(); + + @override + GHeroWith2FragmentsVars rebuild( + void Function(GHeroWith2FragmentsVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroWith2FragmentsVarsBuilder toBuilder() => + new GHeroWith2FragmentsVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroWith2FragmentsVars && first == other.first; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, first.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroWith2FragmentsVars') + ..add('first', first)) + .toString(); + } +} + +class GHeroWith2FragmentsVarsBuilder + implements + Builder { + _$GHeroWith2FragmentsVars? _$v; + + _i1.Value? _first; + _i1.Value? get first => _$this._first; + set first(_i1.Value? first) => _$this._first = first; + + GHeroWith2FragmentsVarsBuilder() { + GHeroWith2FragmentsVars._initializeBuilder(this); + } + + GHeroWith2FragmentsVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _first = $v.first; + _$v = null; + } + return this; + } + + @override + void replace(GHeroWith2FragmentsVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroWith2FragmentsVars; + } + + @override + void update(void Function(GHeroWith2FragmentsVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroWith2FragmentsVars build() => _build(); + + _$GHeroWith2FragmentsVars _build() { + final _$result = _$v ?? new _$GHeroWith2FragmentsVars._(first: first); + replace(_$result); + return _$result; + } +} + +class _$GheroNameVars extends GheroNameVars { + factory _$GheroNameVars([void Function(GheroNameVarsBuilder)? updates]) => + (new GheroNameVarsBuilder()..update(updates))._build(); + + _$GheroNameVars._() : super._(); + + @override + GheroNameVars rebuild(void Function(GheroNameVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GheroNameVarsBuilder toBuilder() => new GheroNameVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GheroNameVars; + } + + @override + int get hashCode { + return 669227084; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GheroNameVars').toString(); + } +} + +class GheroNameVarsBuilder + implements Builder { + _$GheroNameVars? _$v; + + GheroNameVarsBuilder(); + + @override + void replace(GheroNameVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GheroNameVars; + } + + @override + void update(void Function(GheroNameVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GheroNameVars build() => _build(); + + _$GheroNameVars _build() { + final _$result = _$v ?? new _$GheroNameVars._(); + replace(_$result); + return _$result; + } +} + +class _$GheroIdVars extends GheroIdVars { + factory _$GheroIdVars([void Function(GheroIdVarsBuilder)? updates]) => + (new GheroIdVarsBuilder()..update(updates))._build(); + + _$GheroIdVars._() : super._(); + + @override + GheroIdVars rebuild(void Function(GheroIdVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GheroIdVarsBuilder toBuilder() => new GheroIdVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GheroIdVars; + } + + @override + int get hashCode { + return 474459980; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GheroIdVars').toString(); + } +} + +class GheroIdVarsBuilder implements Builder { + _$GheroIdVars? _$v; + + GheroIdVarsBuilder(); + + @override + void replace(GheroIdVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GheroIdVars; + } + + @override + void update(void Function(GheroIdVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GheroIdVars build() => _build(); + + _$GheroIdVars _build() { + final _$result = _$v ?? new _$GheroIdVars._(); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/fragments/fragment_with_scalar_var.graphql b/codegen/end_to_end_test_tristate/lib/fragments/fragment_with_scalar_var.graphql new file mode 100644 index 00000000..1de12ca1 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/fragment_with_scalar_var.graphql @@ -0,0 +1,13 @@ +fragment PostFragmentForUser1 on Post { + id + favoritedUsers(filter: {premium: true}) { + totalCount + } +} + +query PostsWithFixedVariable($filter: Json) { + posts(filter: $filter) { + ...PostFragmentForUser1 + } +} + diff --git a/codegen/end_to_end_test_tristate/lib/fragments/hero_with_fragments.graphql b/codegen/end_to_end_test_tristate/lib/fragments/hero_with_fragments.graphql new file mode 100644 index 00000000..649c74fb --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/hero_with_fragments.graphql @@ -0,0 +1,22 @@ +query HeroWithFragments($first: Int) { + hero(episode: JEDI) { + ...comparisonFields + } +} + +fragment heroData on Character { + name +} + +fragment comparisonFields on Character { + id + ...heroData + friendsConnection(first: $first) { + totalCount + edges { + node { + ...heroData + } + } + } +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/hero_with_interface_subtyped_fragments.graphql b/codegen/end_to_end_test_tristate/lib/fragments/hero_with_interface_subtyped_fragments.graphql new file mode 100644 index 00000000..ef82071b --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/hero_with_interface_subtyped_fragments.graphql @@ -0,0 +1,38 @@ +query HeroWithInterfaceSubTypedFragments($episode: Episode!) { + hero(episode: $episode) { + ...heroFieldsFragment + } +} + +fragment heroFieldsFragment on Character { + id + name + + ...on Human { + ...humanFieldsFragment + } + + ...on Droid { + ...droidFieldsFragment + } +} + +fragment humanFieldsFragment on Human { + homePlanet + friends { + ...on Droid { + id + name + ...droidFieldsFragment + } + ...on Human { + id + name + homePlanet + } + } +} + +fragment droidFieldsFragment on Droid { + primaryFunction +} diff --git a/codegen/end_to_end_test_tristate/lib/fragments/multiple_fragments.graphql b/codegen/end_to_end_test_tristate/lib/fragments/multiple_fragments.graphql new file mode 100644 index 00000000..d253c0c8 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/fragments/multiple_fragments.graphql @@ -0,0 +1,17 @@ + + +fragment heroName on Character { + name +} + +fragment heroId on Character { + id +} + + +query HeroWith2Fragments($first: Int) { + hero(episode: JEDI) { + ...heroName + ...heroId + } +} diff --git a/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.ast.gql.dart b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.ast.gql.dart new file mode 100644 index 00000000..3b75b47a --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.ast.gql.dart @@ -0,0 +1,1181 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const schema = _i1.SchemaDefinitionNode( + directives: [], + operationTypes: [ + _i1.OperationTypeDefinitionNode( + operation: _i1.OperationType.query, + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Query'), + isNonNull: false, + ), + ), + _i1.OperationTypeDefinitionNode( + operation: _i1.OperationType.mutation, + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Mutation'), + isNonNull: false, + ), + ), + _i1.OperationTypeDefinitionNode( + operation: _i1.OperationType.subscription, + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Subscription'), + isNonNull: false, + ), + ), + ], +); +const Gextends = _i1.DirectiveDefinitionNode( + name: _i1.NameNode(value: 'extends'), + args: [], + locations: [ + _i1.DirectiveLocation.object, + _i1.DirectiveLocation.interface, + ], + repeatable: false, +); +const Query = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'Query'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'hero'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'episode'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Episode'), + isNonNull: false, + ), + defaultValue: null, + ) + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'reviews'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'episode'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Episode'), + isNonNull: true, + ), + defaultValue: null, + ) + ], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Review'), + isNonNull: false, + ), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'search'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'text'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'String'), + isNonNull: false, + ), + defaultValue: null, + ) + ], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'SearchResult'), + isNonNull: false, + ), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'character'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'id'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + defaultValue: null, + ) + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'droid'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'id'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + defaultValue: null, + ) + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Droid'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'human'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'id'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + defaultValue: null, + ) + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Human'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'starship'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'id'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + defaultValue: null, + ) + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Starship'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'posts'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'userId'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'filter'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Json'), + isNonNull: false, + ), + defaultValue: null, + ), + ], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Post'), + isNonNull: false, + ), + isNonNull: false, + ), + ), + ], +); +const Mutation = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'Mutation'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'createReview'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'episode'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Episode'), + isNonNull: false, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'review'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ReviewInput'), + isNonNull: true, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'createdAt'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Date'), + isNonNull: false, + ), + defaultValue: null, + ), + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Review'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'createCustomField'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'input'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'CustomFieldInput'), + isNonNull: true, + ), + defaultValue: null, + ) + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'CustomField'), + isNonNull: false, + ), + ), + ], +); +const Subscription = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'Subscription'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'reviewAdded'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'episode'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Episode'), + isNonNull: false, + ), + defaultValue: null, + ) + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Review'), + isNonNull: false, + ), + ) + ], +); +const Episode = _i1.EnumTypeDefinitionNode( + name: _i1.NameNode(value: 'Episode'), + directives: [], + values: [ + _i1.EnumValueDefinitionNode( + name: _i1.NameNode(value: 'NEWHOPE'), + directives: [], + ), + _i1.EnumValueDefinitionNode( + name: _i1.NameNode(value: 'EMPIRE'), + directives: [], + ), + _i1.EnumValueDefinitionNode( + name: _i1.NameNode(value: 'JEDI'), + directives: [], + ), + ], +); +const Character = _i1.InterfaceTypeDefinitionNode( + name: _i1.NameNode(value: 'Character'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'id'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'name'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'String'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'friends'), + directives: [], + args: [], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + ), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'friendsConnection'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'first'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: false, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'after'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: false, + ), + defaultValue: null, + ), + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'FriendsConnection'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'appearsIn'), + directives: [], + args: [], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Episode'), + isNonNull: false, + ), + isNonNull: true, + ), + ), + ], +); +const LengthUnit = _i1.EnumTypeDefinitionNode( + name: _i1.NameNode(value: 'LengthUnit'), + directives: [], + values: [ + _i1.EnumValueDefinitionNode( + name: _i1.NameNode(value: 'METER'), + directives: [], + ), + _i1.EnumValueDefinitionNode( + name: _i1.NameNode(value: 'FOOT'), + directives: [], + ), + ], +); +const Human = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'Human'), + directives: [], + interfaces: [ + _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + ) + ], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'id'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'name'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'String'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'homePlanet'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'String'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'height'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'unit'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'LengthUnit'), + isNonNull: false, + ), + defaultValue: _i1.EnumValueNode(name: _i1.NameNode(value: 'METER')), + ) + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Float'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'mass'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Float'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'friends'), + directives: [], + args: [], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + ), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'friendsConnection'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'first'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: false, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'after'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: false, + ), + defaultValue: null, + ), + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'FriendsConnection'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'appearsIn'), + directives: [], + args: [], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Episode'), + isNonNull: false, + ), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'starships'), + directives: [], + args: [], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Starship'), + isNonNull: false, + ), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'birthday'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Date'), + isNonNull: true, + ), + ), + ], +); +const Droid = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'Droid'), + directives: [], + interfaces: [ + _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + ) + ], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'id'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'name'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'String'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'friends'), + directives: [], + args: [], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + ), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'friendsConnection'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'first'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: false, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'after'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: false, + ), + defaultValue: null, + ), + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'FriendsConnection'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'appearsIn'), + directives: [], + args: [], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Episode'), + isNonNull: false, + ), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'primaryFunction'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'String'), + isNonNull: false, + ), + ), + ], +); +const FriendsConnection = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'FriendsConnection'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'totalCount'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'edges'), + directives: [], + args: [], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'FriendsEdge'), + isNonNull: false, + ), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'friends'), + directives: [], + args: [], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + ), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'pageInfo'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'PageInfo'), + isNonNull: true, + ), + ), + ], +); +const FriendsEdge = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'FriendsEdge'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'cursor'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'node'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Character'), + isNonNull: false, + ), + ), + ], +); +const PageInfo = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'PageInfo'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'startCursor'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'endCursor'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'hasNextPage'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Boolean'), + isNonNull: true, + ), + ), + ], +); +const Review = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'Review'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'episode'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Episode'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'stars'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'commentary'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'String'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'createdAt'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Date'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'seenOn'), + directives: [], + args: [], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Date'), + isNonNull: true, + ), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'custom'), + directives: [], + args: [], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'CustomField'), + isNonNull: true, + ), + isNonNull: true, + ), + ), + ], +); +const ReviewInput = _i1.InputObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'ReviewInput'), + directives: [], + fields: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'stars'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: true, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'commentary'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'String'), + isNonNull: false, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'favorite_color'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ColorInput'), + isNonNull: false, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'seenOn'), + directives: [], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Date'), + isNonNull: false, + ), + isNonNull: false, + ), + defaultValue: null, + ), + ], +); +const CustomFieldInput = _i1.InputObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'CustomFieldInput'), + directives: [], + fields: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'id'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'customField'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'CustomField'), + isNonNull: false, + ), + defaultValue: null, + ), + ], +); +const ColorInput = _i1.InputObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'ColorInput'), + directives: [], + fields: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'red'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: true, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'green'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: true, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'blue'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: true, + ), + defaultValue: null, + ), + ], +); +const Starship = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'Starship'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'id'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'name'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'String'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'length'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'unit'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'LengthUnit'), + isNonNull: false, + ), + defaultValue: _i1.EnumValueNode(name: _i1.NameNode(value: 'METER')), + ) + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Float'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'coordinates'), + directives: [], + args: [], + type: _i1.ListTypeNode( + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Float'), + isNonNull: true, + ), + isNonNull: true, + ), + isNonNull: false, + ), + ), + ], +); +const Post = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'Post'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'id'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'body'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'String'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'favoritedUsers'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'where'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'PostLikesInput'), + isNonNull: false, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'filter'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Json'), + isNonNull: false, + ), + defaultValue: null, + ), + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'PostLikes'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'likedUsers'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'where'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'PostFavoritesInput'), + isNonNull: false, + ), + defaultValue: null, + ) + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'PostFavorites'), + isNonNull: false, + ), + ), + ], +); +const PostLikes = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'PostLikes'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'totalCount'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: true, + ), + ) + ], +); +const PostFavorites = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'PostFavorites'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'totalCount'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: true, + ), + ) + ], +); +const PostLikesInput = _i1.InputObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'PostLikesInput'), + directives: [], + fields: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'id'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + defaultValue: null, + ) + ], +); +const PostFavoritesInput = _i1.InputObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'PostFavoritesInput'), + directives: [], + fields: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'id'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + defaultValue: null, + ) + ], +); +const SearchResult = _i1.UnionTypeDefinitionNode( + name: _i1.NameNode(value: 'SearchResult'), + directives: [], + types: [ + _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Human'), + isNonNull: false, + ), + _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Droid'), + isNonNull: false, + ), + _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Starship'), + isNonNull: false, + ), + ], +); +const Date = _i1.ScalarTypeDefinitionNode( + name: _i1.NameNode(value: 'Date'), + directives: [], +); +const ISODate = _i1.ScalarTypeDefinitionNode( + name: _i1.NameNode(value: 'ISODate'), + directives: [], +); +const CustomField = _i1.ScalarTypeDefinitionNode( + name: _i1.NameNode(value: 'CustomField'), + directives: [], +); +const Json = _i1.ScalarTypeDefinitionNode( + name: _i1.NameNode(value: 'Json'), + directives: [], +); +const document = _i1.DocumentNode(definitions: [ + schema, + Gextends, + Query, + Mutation, + Subscription, + Episode, + Character, + LengthUnit, + Human, + Droid, + FriendsConnection, + FriendsEdge, + PageInfo, + Review, + ReviewInput, + CustomFieldInput, + ColorInput, + Starship, + Post, + PostLikes, + PostFavorites, + PostLikesInput, + PostFavoritesInput, + SearchResult, + Date, + ISODate, + CustomField, + Json, +]); diff --git a/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.dart b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.dart new file mode 100644 index 00000000..d755beab --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.dart @@ -0,0 +1,476 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/custom_field.dart' as _i2; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i3; +import 'package:gql_code_builder/src/serializers/default_scalar_serializer.dart' + as _i4; +import 'package:gql_exec/value.dart' as _i1; + +part 'schema.schema.gql.g.dart'; + +class GEpisode extends EnumClass { + const GEpisode._(String name) : super(name); + + static const GEpisode NEWHOPE = _$gEpisodeNEWHOPE; + + static const GEpisode EMPIRE = _$gEpisodeEMPIRE; + + static const GEpisode JEDI = _$gEpisodeJEDI; + + static Serializer get serializer => _$gEpisodeSerializer; + + static BuiltSet get values => _$gEpisodeValues; + + static GEpisode valueOf(String name) => _$gEpisodeValueOf(name); +} + +class GLengthUnit extends EnumClass { + const GLengthUnit._(String name) : super(name); + + @BuiltValueEnumConst( + wireName: 'METER', + fallback: true, + ) + static const GLengthUnit METER = _$gLengthUnitMETER; + + static const GLengthUnit FOOT = _$gLengthUnitFOOT; + + static Serializer get serializer => _$gLengthUnitSerializer; + + static BuiltSet get values => _$gLengthUnitValues; + + static GLengthUnit valueOf(String name) => _$gLengthUnitValueOf(name); +} + +abstract class GReviewInput + implements Built { + GReviewInput._(); + + factory GReviewInput([Function(GReviewInputBuilder b) updates]) = + _$GReviewInput; + + int get stars; + _i1.Value? get commentary; + _i1.Value? get favorite_color; + _i1.Value>? get seenOn; + Map toJson() => (_i3.serializers.serializeWith( + GReviewInput.serializer, + this, + ) as Map); + + static GReviewInput? fromJson(Map json) => + _i3.serializers.deserializeWith( + GReviewInput.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => GReviewInputSerializer(); +} + +class GReviewInputSerializer extends StructuredSerializer { + final String wireName = 'GReviewInput'; + + final Iterable types = const [GReviewInput, _$GReviewInput]; + + Iterable serialize( + Serializers serializers, + GReviewInput object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('stars'); + result.add(serializers.serialize(object.stars, + specifiedType: const FullType(int))); + final _$commentaryvalue = object.commentary; + if (_$commentaryvalue case _i1.PresentValue(value: final _$value)) { + result.add('commentary'); + result.add(serializers.serialize(_$value, + specifiedType: const FullType(String))); + } + final _$favorite_colorvalue = object.favorite_color; + if (_$favorite_colorvalue case _i1.PresentValue(value: final _$value)) { + result.add('favorite_color'); + result.add(serializers.serialize(_$value, + specifiedType: const FullType(GColorInput))); + } + final _$seenOnvalue = object.seenOn; + if (_$seenOnvalue case _i1.PresentValue(value: final _$value)) { + result.add('seenOn'); + result.add(serializers.serialize(_$value, + specifiedType: const FullType(BuiltList, [FullType(DateTime)]))); + } + return result; + } + + GReviewInput deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GReviewInputBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'stars': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + builder.stars = fieldValue; + break; + case 'commentary': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + builder.commentary = _i1.PresentValue(fieldValue); + break; + case 'favorite_color': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(GColorInput)) as GColorInput; + builder.favorite_color = _i1.PresentValue(fieldValue); + break; + case 'seenOn': + var fieldValue = serializers.deserialize(value, + specifiedType: + const FullType(BuiltList, [FullType(DateTime)])) + as BuiltList; + builder.seenOn = _i1.PresentValue(fieldValue); + break; + } + } + return builder.build(); + } +} + +abstract class GCustomFieldInput + implements Built { + GCustomFieldInput._(); + + factory GCustomFieldInput([Function(GCustomFieldInputBuilder b) updates]) = + _$GCustomFieldInput; + + String get id; + _i1.Value<_i2.CustomField>? get customField; + Map toJson() => (_i3.serializers.serializeWith( + GCustomFieldInput.serializer, + this, + ) as Map); + + static GCustomFieldInput? fromJson(Map json) => + _i3.serializers.deserializeWith( + GCustomFieldInput.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GCustomFieldInputSerializer(); +} + +class GCustomFieldInputSerializer + extends StructuredSerializer { + final String wireName = 'GCustomFieldInput'; + + final Iterable types = const [GCustomFieldInput, _$GCustomFieldInput]; + + Iterable serialize( + Serializers serializers, + GCustomFieldInput object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('id'); + result.add(serializers.serialize(object.id, + specifiedType: const FullType(String))); + final _$customFieldvalue = object.customField; + if (_$customFieldvalue case _i1.PresentValue(value: final _$value)) { + result.add('customField'); + result.add(serializers.serialize(_$value, + specifiedType: const FullType(_i2.CustomField))); + } + return result; + } + + GCustomFieldInput deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GCustomFieldInputBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'id': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + builder.id = fieldValue; + break; + case 'customField': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i2.CustomField)) + as _i2.CustomField; + builder.customField = _i1.PresentValue(fieldValue); + break; + } + } + return builder.build(); + } +} + +abstract class GColorInput implements Built { + GColorInput._(); + + factory GColorInput([Function(GColorInputBuilder b) updates]) = _$GColorInput; + + int get red; + int get green; + int get blue; + Map toJson() => (_i3.serializers.serializeWith( + GColorInput.serializer, + this, + ) as Map); + + static GColorInput? fromJson(Map json) => + _i3.serializers.deserializeWith( + GColorInput.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => GColorInputSerializer(); +} + +class GColorInputSerializer extends StructuredSerializer { + final String wireName = 'GColorInput'; + + final Iterable types = const [GColorInput, _$GColorInput]; + + Iterable serialize( + Serializers serializers, + GColorInput object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('red'); + result.add( + serializers.serialize(object.red, specifiedType: const FullType(int))); + result.add('green'); + result.add(serializers.serialize(object.green, + specifiedType: const FullType(int))); + result.add('blue'); + result.add( + serializers.serialize(object.blue, specifiedType: const FullType(int))); + return result; + } + + GColorInput deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GColorInputBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'red': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + builder.red = fieldValue; + break; + case 'green': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + builder.green = fieldValue; + break; + case 'blue': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(int)) as int; + builder.blue = fieldValue; + break; + } + } + return builder.build(); + } +} + +abstract class GPostLikesInput + implements Built { + GPostLikesInput._(); + + factory GPostLikesInput([Function(GPostLikesInputBuilder b) updates]) = + _$GPostLikesInput; + + String get id; + Map toJson() => (_i3.serializers.serializeWith( + GPostLikesInput.serializer, + this, + ) as Map); + + static GPostLikesInput? fromJson(Map json) => + _i3.serializers.deserializeWith( + GPostLikesInput.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GPostLikesInputSerializer(); +} + +class GPostLikesInputSerializer extends StructuredSerializer { + final String wireName = 'GPostLikesInput'; + + final Iterable types = const [GPostLikesInput, _$GPostLikesInput]; + + Iterable serialize( + Serializers serializers, + GPostLikesInput object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('id'); + result.add(serializers.serialize(object.id, + specifiedType: const FullType(String))); + return result; + } + + GPostLikesInput deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GPostLikesInputBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'id': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + builder.id = fieldValue; + break; + } + } + return builder.build(); + } +} + +abstract class GPostFavoritesInput + implements Built { + GPostFavoritesInput._(); + + factory GPostFavoritesInput( + [Function(GPostFavoritesInputBuilder b) updates]) = _$GPostFavoritesInput; + + String get id; + Map toJson() => (_i3.serializers.serializeWith( + GPostFavoritesInput.serializer, + this, + ) as Map); + + static GPostFavoritesInput? fromJson(Map json) => + _i3.serializers.deserializeWith( + GPostFavoritesInput.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GPostFavoritesInputSerializer(); +} + +class GPostFavoritesInputSerializer + extends StructuredSerializer { + final String wireName = 'GPostFavoritesInput'; + + final Iterable types = const [ + GPostFavoritesInput, + _$GPostFavoritesInput + ]; + + Iterable serialize( + Serializers serializers, + GPostFavoritesInput object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('id'); + result.add(serializers.serialize(object.id, + specifiedType: const FullType(String))); + return result; + } + + GPostFavoritesInput deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GPostFavoritesInputBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'id': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + builder.id = fieldValue; + break; + } + } + return builder.build(); + } +} + +abstract class GISODate implements Built { + GISODate._(); + + factory GISODate([String? value]) => + _$GISODate((b) => value != null ? (b..value = value) : b); + + String get value; + @BuiltValueSerializer(custom: true) + static Serializer get serializer => + _i4.DefaultScalarSerializer( + (Object serialized) => GISODate((serialized as String?))); +} + +abstract class GJson implements Built { + GJson._(); + + factory GJson([String? value]) => + _$GJson((b) => value != null ? (b..value = value) : b); + + String get value; + @BuiltValueSerializer(custom: true) + static Serializer get serializer => _i4.DefaultScalarSerializer( + (Object serialized) => GJson((serialized as String?))); +} + +const Map> possibleTypesMap = { + 'Character': { + 'Human', + 'Droid', + }, + 'SearchResult': { + 'Human', + 'Droid', + 'Starship', + }, +}; diff --git a/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.g.dart b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.g.dart new file mode 100644 index 00000000..0b62d7aa --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.g.dart @@ -0,0 +1,758 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'schema.schema.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +const GEpisode _$gEpisodeNEWHOPE = const GEpisode._('NEWHOPE'); +const GEpisode _$gEpisodeEMPIRE = const GEpisode._('EMPIRE'); +const GEpisode _$gEpisodeJEDI = const GEpisode._('JEDI'); + +GEpisode _$gEpisodeValueOf(String name) { + switch (name) { + case 'NEWHOPE': + return _$gEpisodeNEWHOPE; + case 'EMPIRE': + return _$gEpisodeEMPIRE; + case 'JEDI': + return _$gEpisodeJEDI; + default: + throw new ArgumentError(name); + } +} + +final BuiltSet _$gEpisodeValues = + new BuiltSet(const [ + _$gEpisodeNEWHOPE, + _$gEpisodeEMPIRE, + _$gEpisodeJEDI, +]); + +const GLengthUnit _$gLengthUnitMETER = const GLengthUnit._('METER'); +const GLengthUnit _$gLengthUnitFOOT = const GLengthUnit._('FOOT'); + +GLengthUnit _$gLengthUnitValueOf(String name) { + switch (name) { + case 'METER': + return _$gLengthUnitMETER; + case 'FOOT': + return _$gLengthUnitFOOT; + default: + return _$gLengthUnitMETER; + } +} + +final BuiltSet _$gLengthUnitValues = + new BuiltSet(const [ + _$gLengthUnitMETER, + _$gLengthUnitFOOT, +]); + +Serializer _$gEpisodeSerializer = new _$GEpisodeSerializer(); +Serializer _$gLengthUnitSerializer = new _$GLengthUnitSerializer(); + +class _$GEpisodeSerializer implements PrimitiveSerializer { + @override + final Iterable types = const [GEpisode]; + @override + final String wireName = 'GEpisode'; + + @override + Object serialize(Serializers serializers, GEpisode object, + {FullType specifiedType = FullType.unspecified}) => + object.name; + + @override + GEpisode deserialize(Serializers serializers, Object serialized, + {FullType specifiedType = FullType.unspecified}) => + GEpisode.valueOf(serialized as String); +} + +class _$GLengthUnitSerializer implements PrimitiveSerializer { + static const Map _toWire = const { + 'METER': 'METER', + }; + static const Map _fromWire = const { + 'METER': 'METER', + }; + + @override + final Iterable types = const [GLengthUnit]; + @override + final String wireName = 'GLengthUnit'; + + @override + Object serialize(Serializers serializers, GLengthUnit object, + {FullType specifiedType = FullType.unspecified}) => + _toWire[object.name] ?? object.name; + + @override + GLengthUnit deserialize(Serializers serializers, Object serialized, + {FullType specifiedType = FullType.unspecified}) => + GLengthUnit.valueOf( + _fromWire[serialized] ?? (serialized is String ? serialized : '')); +} + +class _$GReviewInput extends GReviewInput { + @override + final int stars; + @override + final _i1.Value? commentary; + @override + final _i1.Value? favorite_color; + @override + final _i1.Value>? seenOn; + + factory _$GReviewInput([void Function(GReviewInputBuilder)? updates]) => + (new GReviewInputBuilder()..update(updates))._build(); + + _$GReviewInput._( + {required this.stars, this.commentary, this.favorite_color, this.seenOn}) + : super._() { + BuiltValueNullFieldError.checkNotNull(stars, r'GReviewInput', 'stars'); + } + + @override + GReviewInput rebuild(void Function(GReviewInputBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GReviewInputBuilder toBuilder() => new GReviewInputBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GReviewInput && + stars == other.stars && + commentary == other.commentary && + favorite_color == other.favorite_color && + seenOn == other.seenOn; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, stars.hashCode); + _$hash = $jc(_$hash, commentary.hashCode); + _$hash = $jc(_$hash, favorite_color.hashCode); + _$hash = $jc(_$hash, seenOn.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GReviewInput') + ..add('stars', stars) + ..add('commentary', commentary) + ..add('favorite_color', favorite_color) + ..add('seenOn', seenOn)) + .toString(); + } +} + +class GReviewInputBuilder + implements Builder { + _$GReviewInput? _$v; + + int? _stars; + int? get stars => _$this._stars; + set stars(int? stars) => _$this._stars = stars; + + _i1.Value? _commentary; + _i1.Value? get commentary => _$this._commentary; + set commentary(_i1.Value? commentary) => + _$this._commentary = commentary; + + _i1.Value? _favorite_color; + _i1.Value? get favorite_color => _$this._favorite_color; + set favorite_color(_i1.Value? favorite_color) => + _$this._favorite_color = favorite_color; + + _i1.Value>? _seenOn; + _i1.Value>? get seenOn => _$this._seenOn; + set seenOn(_i1.Value>? seenOn) => + _$this._seenOn = seenOn; + + GReviewInputBuilder(); + + GReviewInputBuilder get _$this { + final $v = _$v; + if ($v != null) { + _stars = $v.stars; + _commentary = $v.commentary; + _favorite_color = $v.favorite_color; + _seenOn = $v.seenOn; + _$v = null; + } + return this; + } + + @override + void replace(GReviewInput other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GReviewInput; + } + + @override + void update(void Function(GReviewInputBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GReviewInput build() => _build(); + + _$GReviewInput _build() { + final _$result = _$v ?? + new _$GReviewInput._( + stars: BuiltValueNullFieldError.checkNotNull( + stars, r'GReviewInput', 'stars'), + commentary: commentary, + favorite_color: favorite_color, + seenOn: seenOn); + replace(_$result); + return _$result; + } +} + +class _$GCustomFieldInput extends GCustomFieldInput { + @override + final String id; + @override + final _i1.Value<_i2.CustomField>? customField; + + factory _$GCustomFieldInput( + [void Function(GCustomFieldInputBuilder)? updates]) => + (new GCustomFieldInputBuilder()..update(updates))._build(); + + _$GCustomFieldInput._({required this.id, this.customField}) : super._() { + BuiltValueNullFieldError.checkNotNull(id, r'GCustomFieldInput', 'id'); + } + + @override + GCustomFieldInput rebuild(void Function(GCustomFieldInputBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GCustomFieldInputBuilder toBuilder() => + new GCustomFieldInputBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GCustomFieldInput && + id == other.id && + customField == other.customField; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, customField.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GCustomFieldInput') + ..add('id', id) + ..add('customField', customField)) + .toString(); + } +} + +class GCustomFieldInputBuilder + implements Builder { + _$GCustomFieldInput? _$v; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + _i1.Value<_i2.CustomField>? _customField; + _i1.Value<_i2.CustomField>? get customField => _$this._customField; + set customField(_i1.Value<_i2.CustomField>? customField) => + _$this._customField = customField; + + GCustomFieldInputBuilder(); + + GCustomFieldInputBuilder get _$this { + final $v = _$v; + if ($v != null) { + _id = $v.id; + _customField = $v.customField; + _$v = null; + } + return this; + } + + @override + void replace(GCustomFieldInput other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GCustomFieldInput; + } + + @override + void update(void Function(GCustomFieldInputBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GCustomFieldInput build() => _build(); + + _$GCustomFieldInput _build() { + final _$result = _$v ?? + new _$GCustomFieldInput._( + id: BuiltValueNullFieldError.checkNotNull( + id, r'GCustomFieldInput', 'id'), + customField: customField); + replace(_$result); + return _$result; + } +} + +class _$GColorInput extends GColorInput { + @override + final int red; + @override + final int green; + @override + final int blue; + + factory _$GColorInput([void Function(GColorInputBuilder)? updates]) => + (new GColorInputBuilder()..update(updates))._build(); + + _$GColorInput._({required this.red, required this.green, required this.blue}) + : super._() { + BuiltValueNullFieldError.checkNotNull(red, r'GColorInput', 'red'); + BuiltValueNullFieldError.checkNotNull(green, r'GColorInput', 'green'); + BuiltValueNullFieldError.checkNotNull(blue, r'GColorInput', 'blue'); + } + + @override + GColorInput rebuild(void Function(GColorInputBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GColorInputBuilder toBuilder() => new GColorInputBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GColorInput && + red == other.red && + green == other.green && + blue == other.blue; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, red.hashCode); + _$hash = $jc(_$hash, green.hashCode); + _$hash = $jc(_$hash, blue.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GColorInput') + ..add('red', red) + ..add('green', green) + ..add('blue', blue)) + .toString(); + } +} + +class GColorInputBuilder implements Builder { + _$GColorInput? _$v; + + int? _red; + int? get red => _$this._red; + set red(int? red) => _$this._red = red; + + int? _green; + int? get green => _$this._green; + set green(int? green) => _$this._green = green; + + int? _blue; + int? get blue => _$this._blue; + set blue(int? blue) => _$this._blue = blue; + + GColorInputBuilder(); + + GColorInputBuilder get _$this { + final $v = _$v; + if ($v != null) { + _red = $v.red; + _green = $v.green; + _blue = $v.blue; + _$v = null; + } + return this; + } + + @override + void replace(GColorInput other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GColorInput; + } + + @override + void update(void Function(GColorInputBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GColorInput build() => _build(); + + _$GColorInput _build() { + final _$result = _$v ?? + new _$GColorInput._( + red: BuiltValueNullFieldError.checkNotNull( + red, r'GColorInput', 'red'), + green: BuiltValueNullFieldError.checkNotNull( + green, r'GColorInput', 'green'), + blue: BuiltValueNullFieldError.checkNotNull( + blue, r'GColorInput', 'blue')); + replace(_$result); + return _$result; + } +} + +class _$GPostLikesInput extends GPostLikesInput { + @override + final String id; + + factory _$GPostLikesInput([void Function(GPostLikesInputBuilder)? updates]) => + (new GPostLikesInputBuilder()..update(updates))._build(); + + _$GPostLikesInput._({required this.id}) : super._() { + BuiltValueNullFieldError.checkNotNull(id, r'GPostLikesInput', 'id'); + } + + @override + GPostLikesInput rebuild(void Function(GPostLikesInputBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostLikesInputBuilder toBuilder() => + new GPostLikesInputBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostLikesInput && id == other.id; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostLikesInput')..add('id', id)) + .toString(); + } +} + +class GPostLikesInputBuilder + implements Builder { + _$GPostLikesInput? _$v; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + GPostLikesInputBuilder(); + + GPostLikesInputBuilder get _$this { + final $v = _$v; + if ($v != null) { + _id = $v.id; + _$v = null; + } + return this; + } + + @override + void replace(GPostLikesInput other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostLikesInput; + } + + @override + void update(void Function(GPostLikesInputBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostLikesInput build() => _build(); + + _$GPostLikesInput _build() { + final _$result = _$v ?? + new _$GPostLikesInput._( + id: BuiltValueNullFieldError.checkNotNull( + id, r'GPostLikesInput', 'id')); + replace(_$result); + return _$result; + } +} + +class _$GPostFavoritesInput extends GPostFavoritesInput { + @override + final String id; + + factory _$GPostFavoritesInput( + [void Function(GPostFavoritesInputBuilder)? updates]) => + (new GPostFavoritesInputBuilder()..update(updates))._build(); + + _$GPostFavoritesInput._({required this.id}) : super._() { + BuiltValueNullFieldError.checkNotNull(id, r'GPostFavoritesInput', 'id'); + } + + @override + GPostFavoritesInput rebuild( + void Function(GPostFavoritesInputBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostFavoritesInputBuilder toBuilder() => + new GPostFavoritesInputBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostFavoritesInput && id == other.id; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GPostFavoritesInput')..add('id', id)) + .toString(); + } +} + +class GPostFavoritesInputBuilder + implements Builder { + _$GPostFavoritesInput? _$v; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + GPostFavoritesInputBuilder(); + + GPostFavoritesInputBuilder get _$this { + final $v = _$v; + if ($v != null) { + _id = $v.id; + _$v = null; + } + return this; + } + + @override + void replace(GPostFavoritesInput other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostFavoritesInput; + } + + @override + void update(void Function(GPostFavoritesInputBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostFavoritesInput build() => _build(); + + _$GPostFavoritesInput _build() { + final _$result = _$v ?? + new _$GPostFavoritesInput._( + id: BuiltValueNullFieldError.checkNotNull( + id, r'GPostFavoritesInput', 'id')); + replace(_$result); + return _$result; + } +} + +class _$GISODate extends GISODate { + @override + final String value; + + factory _$GISODate([void Function(GISODateBuilder)? updates]) => + (new GISODateBuilder()..update(updates))._build(); + + _$GISODate._({required this.value}) : super._() { + BuiltValueNullFieldError.checkNotNull(value, r'GISODate', 'value'); + } + + @override + GISODate rebuild(void Function(GISODateBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GISODateBuilder toBuilder() => new GISODateBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GISODate && value == other.value; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, value.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GISODate')..add('value', value)) + .toString(); + } +} + +class GISODateBuilder implements Builder { + _$GISODate? _$v; + + String? _value; + String? get value => _$this._value; + set value(String? value) => _$this._value = value; + + GISODateBuilder(); + + GISODateBuilder get _$this { + final $v = _$v; + if ($v != null) { + _value = $v.value; + _$v = null; + } + return this; + } + + @override + void replace(GISODate other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GISODate; + } + + @override + void update(void Function(GISODateBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GISODate build() => _build(); + + _$GISODate _build() { + final _$result = _$v ?? + new _$GISODate._( + value: BuiltValueNullFieldError.checkNotNull( + value, r'GISODate', 'value')); + replace(_$result); + return _$result; + } +} + +class _$GJson extends GJson { + @override + final String value; + + factory _$GJson([void Function(GJsonBuilder)? updates]) => + (new GJsonBuilder()..update(updates))._build(); + + _$GJson._({required this.value}) : super._() { + BuiltValueNullFieldError.checkNotNull(value, r'GJson', 'value'); + } + + @override + GJson rebuild(void Function(GJsonBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GJsonBuilder toBuilder() => new GJsonBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GJson && value == other.value; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, value.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GJson')..add('value', value)) + .toString(); + } +} + +class GJsonBuilder implements Builder { + _$GJson? _$v; + + String? _value; + String? get value => _$this._value; + set value(String? value) => _$this._value = value; + + GJsonBuilder(); + + GJsonBuilder get _$this { + final $v = _$v; + if ($v != null) { + _value = $v.value; + _$v = null; + } + return this; + } + + @override + void replace(GJson other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GJson; + } + + @override + void update(void Function(GJsonBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GJson build() => _build(); + + _$GJson _build() { + final _$result = _$v ?? + new _$GJson._( + value: BuiltValueNullFieldError.checkNotNull( + value, r'GJson', 'value')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/graphql/__generated__/serializers.gql.dart b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/serializers.gql.dart new file mode 100644 index 00000000..15090df8 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/serializers.gql.dart @@ -0,0 +1,264 @@ +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/serializer.dart'; +import 'package:built_value/standard_json_plugin.dart' show StandardJsonPlugin; +import 'package:end_to_end_test_tristate/aliases/__generated__/alias_var_fragment.data.gql.dart' + show + GPostFragmentData, + GPostFragmentData_isFavorited, + GPostFragmentData_isLiked, + GPostsData, + GPostsData_posts, + GPostsData_posts_isFavorited, + GPostsData_posts_isLiked; +import 'package:end_to_end_test_tristate/aliases/__generated__/alias_var_fragment.req.gql.dart' + show GPosts; +import 'package:end_to_end_test_tristate/aliases/__generated__/alias_var_fragment.var.gql.dart' + show GPostFragmentVars, GPostsVars; +import 'package:end_to_end_test_tristate/aliases/__generated__/aliased_hero.data.gql.dart' + show + GAliasedHeroData, + GAliasedHeroData_empireHero, + GAliasedHeroData_jediHero; +import 'package:end_to_end_test_tristate/aliases/__generated__/aliased_hero.req.gql.dart' + show GAliasedHero; +import 'package:end_to_end_test_tristate/aliases/__generated__/aliased_hero.var.gql.dart' + show GAliasedHeroVars; +import 'package:end_to_end_test_tristate/custom_field.dart'; +import 'package:end_to_end_test_tristate/custom_field_serializer.dart' + show CustomFieldSerializer; +import 'package:end_to_end_test_tristate/date_serializer.dart' + show DateSerializer; +import 'package:end_to_end_test_tristate/fragments/__generated__/fragment_with_scalar_var.data.gql.dart' + show + GPostFragmentForUser1Data, + GPostFragmentForUser1Data_favoritedUsers, + GPostsWithFixedVariableData, + GPostsWithFixedVariableData_posts, + GPostsWithFixedVariableData_posts_favoritedUsers; +import 'package:end_to_end_test_tristate/fragments/__generated__/fragment_with_scalar_var.req.gql.dart' + show GPostsWithFixedVariable; +import 'package:end_to_end_test_tristate/fragments/__generated__/fragment_with_scalar_var.var.gql.dart' + show GPostFragmentForUser1Vars, GPostsWithFixedVariableVars; +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_fragments.data.gql.dart' + show + GHeroWithFragmentsData, + GHeroWithFragmentsData_hero, + GHeroWithFragmentsData_hero_friendsConnection, + GHeroWithFragmentsData_hero_friendsConnection_edges, + GHeroWithFragmentsData_hero_friendsConnection_edges_node, + GcomparisonFieldsData, + GcomparisonFieldsData_friendsConnection, + GcomparisonFieldsData_friendsConnection_edges, + GcomparisonFieldsData_friendsConnection_edges_node, + GheroDataData; +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_fragments.req.gql.dart' + show GHeroWithFragments; +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_fragments.var.gql.dart' + show GHeroWithFragmentsVars, GcomparisonFieldsVars, GheroDataVars; +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.dart' + show + GheroFieldsFragmentData, + GheroFieldsFragmentData__asHuman_friends, + GhumanFieldsFragmentData_friends, + GHeroWithInterfaceSubTypedFragmentsData, + GHeroWithInterfaceSubTypedFragmentsData_hero, + GdroidFieldsFragmentData, + GheroFieldsFragmentData__asDroid, + GheroFieldsFragmentData__asHuman, + GheroFieldsFragmentData__asHuman_friends__asDroid, + GheroFieldsFragmentData__asHuman_friends__asHuman, + GheroFieldsFragmentData__asHuman_friends__base, + GheroFieldsFragmentData__base, + GhumanFieldsFragmentData, + GhumanFieldsFragmentData_friends__asDroid, + GhumanFieldsFragmentData_friends__asHuman, + GhumanFieldsFragmentData_friends__base; +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_interface_subtyped_fragments.req.gql.dart' + show GHeroWithInterfaceSubTypedFragments; +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart' + show + GHeroWithInterfaceSubTypedFragmentsVars, + GdroidFieldsFragmentVars, + GheroFieldsFragmentVars, + GhumanFieldsFragmentVars; +import 'package:end_to_end_test_tristate/fragments/__generated__/multiple_fragments.data.gql.dart' + show + GHeroWith2FragmentsData, + GHeroWith2FragmentsData_hero, + GheroIdData, + GheroNameData; +import 'package:end_to_end_test_tristate/fragments/__generated__/multiple_fragments.req.gql.dart' + show GHeroWith2Fragments; +import 'package:end_to_end_test_tristate/fragments/__generated__/multiple_fragments.var.gql.dart' + show GHeroWith2FragmentsVars, GheroIdVars, GheroNameVars; +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart' + show + GColorInput, + GCustomFieldInput, + GEpisode, + GISODate, + GJson, + GLengthUnit, + GPostFavoritesInput, + GPostLikesInput, + GReviewInput; +import 'package:end_to_end_test_tristate/interfaces/__generated__/hero_for_episode.data.gql.dart' + show + GHeroForEpisodeData_hero, + GDroidFragmentData, + GHeroForEpisodeData, + GHeroForEpisodeData_hero__asDroid, + GHeroForEpisodeData_hero__asDroid_friends, + GHeroForEpisodeData_hero__base, + GHeroForEpisodeData_hero__base_friends; +import 'package:end_to_end_test_tristate/interfaces/__generated__/hero_for_episode.req.gql.dart' + show GHeroForEpisode; +import 'package:end_to_end_test_tristate/interfaces/__generated__/hero_for_episode.var.gql.dart' + show GDroidFragmentVars, GHeroForEpisodeVars; +import 'package:end_to_end_test_tristate/no_vars/__generated__/hero_no_vars.data.gql.dart' + show GHeroNoVarsData, GHeroNoVarsData_hero; +import 'package:end_to_end_test_tristate/no_vars/__generated__/hero_no_vars.req.gql.dart' + show GHeroNoVars; +import 'package:end_to_end_test_tristate/no_vars/__generated__/hero_no_vars.var.gql.dart' + show GHeroNoVarsVars; +import 'package:end_to_end_test_tristate/scalars/__generated__/review_with_date.data.gql.dart' + show GReviewWithDateData, GReviewWithDateData_createReview; +import 'package:end_to_end_test_tristate/scalars/__generated__/review_with_date.req.gql.dart' + show GReviewWithDate; +import 'package:end_to_end_test_tristate/scalars/__generated__/review_with_date.var.gql.dart' + show GReviewWithDateVars; +import 'package:end_to_end_test_tristate/variables/__generated__/create_custom_field.data.gql.dart' + show GCreateCustomFieldData; +import 'package:end_to_end_test_tristate/variables/__generated__/create_custom_field.req.gql.dart' + show GCreateCustomField; +import 'package:end_to_end_test_tristate/variables/__generated__/create_custom_field.var.gql.dart' + show GCreateCustomFieldVars; +import 'package:end_to_end_test_tristate/variables/__generated__/create_review.data.gql.dart' + show GCreateReviewData, GCreateReviewData_createReview; +import 'package:end_to_end_test_tristate/variables/__generated__/create_review.req.gql.dart' + show GCreateReview; +import 'package:end_to_end_test_tristate/variables/__generated__/create_review.var.gql.dart' + show GCreateReviewVars; +import 'package:end_to_end_test_tristate/variables/__generated__/human_with_args.data.gql.dart' + show GHumanWithArgsData, GHumanWithArgsData_human; +import 'package:end_to_end_test_tristate/variables/__generated__/human_with_args.req.gql.dart' + show GHumanWithArgs; +import 'package:end_to_end_test_tristate/variables/__generated__/human_with_args.var.gql.dart' + show GHumanWithArgsVars; +import 'package:gql_code_builder/src/serializers/operation_serializer.dart' + show OperationSerializer; + +part 'serializers.gql.g.dart'; + +final SerializersBuilder _serializersBuilder = _$serializers.toBuilder() + ..add(OperationSerializer()) + ..add(DateSerializer()) + ..add(CustomFieldSerializer()) + ..add(GHeroForEpisodeData_hero.serializer) + ..add(GheroFieldsFragmentData.serializer) + ..add(GheroFieldsFragmentData__asHuman_friends.serializer) + ..add(GhumanFieldsFragmentData_friends.serializer) + ..addPlugin(StandardJsonPlugin()); +@SerializersFor([ + GAliasedHero, + GAliasedHeroData, + GAliasedHeroData_empireHero, + GAliasedHeroData_jediHero, + GAliasedHeroVars, + GColorInput, + GCreateCustomField, + GCreateCustomFieldData, + GCreateCustomFieldVars, + GCreateReview, + GCreateReviewData, + GCreateReviewData_createReview, + GCreateReviewVars, + GCustomFieldInput, + GDroidFragmentData, + GDroidFragmentVars, + GEpisode, + GHeroForEpisode, + GHeroForEpisodeData, + GHeroForEpisodeData_hero__asDroid, + GHeroForEpisodeData_hero__asDroid_friends, + GHeroForEpisodeData_hero__base, + GHeroForEpisodeData_hero__base_friends, + GHeroForEpisodeVars, + GHeroNoVars, + GHeroNoVarsData, + GHeroNoVarsData_hero, + GHeroNoVarsVars, + GHeroWith2Fragments, + GHeroWith2FragmentsData, + GHeroWith2FragmentsData_hero, + GHeroWith2FragmentsVars, + GHeroWithFragments, + GHeroWithFragmentsData, + GHeroWithFragmentsData_hero, + GHeroWithFragmentsData_hero_friendsConnection, + GHeroWithFragmentsData_hero_friendsConnection_edges, + GHeroWithFragmentsData_hero_friendsConnection_edges_node, + GHeroWithFragmentsVars, + GHeroWithInterfaceSubTypedFragments, + GHeroWithInterfaceSubTypedFragmentsData, + GHeroWithInterfaceSubTypedFragmentsData_hero, + GHeroWithInterfaceSubTypedFragmentsVars, + GHumanWithArgs, + GHumanWithArgsData, + GHumanWithArgsData_human, + GHumanWithArgsVars, + GISODate, + GJson, + GLengthUnit, + GPostFavoritesInput, + GPostFragmentData, + GPostFragmentData_isFavorited, + GPostFragmentData_isLiked, + GPostFragmentForUser1Data, + GPostFragmentForUser1Data_favoritedUsers, + GPostFragmentForUser1Vars, + GPostFragmentVars, + GPostLikesInput, + GPosts, + GPostsData, + GPostsData_posts, + GPostsData_posts_isFavorited, + GPostsData_posts_isLiked, + GPostsVars, + GPostsWithFixedVariable, + GPostsWithFixedVariableData, + GPostsWithFixedVariableData_posts, + GPostsWithFixedVariableData_posts_favoritedUsers, + GPostsWithFixedVariableVars, + GReviewInput, + GReviewWithDate, + GReviewWithDateData, + GReviewWithDateData_createReview, + GReviewWithDateVars, + GcomparisonFieldsData, + GcomparisonFieldsData_friendsConnection, + GcomparisonFieldsData_friendsConnection_edges, + GcomparisonFieldsData_friendsConnection_edges_node, + GcomparisonFieldsVars, + GdroidFieldsFragmentData, + GdroidFieldsFragmentVars, + GheroDataData, + GheroDataVars, + GheroFieldsFragmentData__asDroid, + GheroFieldsFragmentData__asHuman, + GheroFieldsFragmentData__asHuman_friends__asDroid, + GheroFieldsFragmentData__asHuman_friends__asHuman, + GheroFieldsFragmentData__asHuman_friends__base, + GheroFieldsFragmentData__base, + GheroFieldsFragmentVars, + GheroIdData, + GheroIdVars, + GheroNameData, + GheroNameVars, + GhumanFieldsFragmentData, + GhumanFieldsFragmentData_friends__asDroid, + GhumanFieldsFragmentData_friends__asHuman, + GhumanFieldsFragmentData_friends__base, + GhumanFieldsFragmentVars, +]) +final Serializers serializers = _serializersBuilder.build(); diff --git a/codegen/end_to_end_test_tristate/lib/graphql/__generated__/serializers.gql.g.dart b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/serializers.gql.g.dart new file mode 100644 index 00000000..86cbb01f --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/serializers.gql.g.dart @@ -0,0 +1,167 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'serializers.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializers _$serializers = (new Serializers().toBuilder() + ..add(GAliasedHero.serializer) + ..add(GAliasedHeroData.serializer) + ..add(GAliasedHeroData_empireHero.serializer) + ..add(GAliasedHeroData_jediHero.serializer) + ..add(GAliasedHeroVars.serializer) + ..add(GColorInput.serializer) + ..add(GCreateCustomField.serializer) + ..add(GCreateCustomFieldData.serializer) + ..add(GCreateCustomFieldVars.serializer) + ..add(GCreateReview.serializer) + ..add(GCreateReviewData.serializer) + ..add(GCreateReviewData_createReview.serializer) + ..add(GCreateReviewVars.serializer) + ..add(GCustomFieldInput.serializer) + ..add(GDroidFragmentData.serializer) + ..add(GDroidFragmentVars.serializer) + ..add(GEpisode.serializer) + ..add(GHeroForEpisode.serializer) + ..add(GHeroForEpisodeData.serializer) + ..add(GHeroForEpisodeData_hero__asDroid.serializer) + ..add(GHeroForEpisodeData_hero__asDroid_friends.serializer) + ..add(GHeroForEpisodeData_hero__base.serializer) + ..add(GHeroForEpisodeData_hero__base_friends.serializer) + ..add(GHeroForEpisodeVars.serializer) + ..add(GHeroNoVars.serializer) + ..add(GHeroNoVarsData.serializer) + ..add(GHeroNoVarsData_hero.serializer) + ..add(GHeroNoVarsVars.serializer) + ..add(GHeroWith2Fragments.serializer) + ..add(GHeroWith2FragmentsData.serializer) + ..add(GHeroWith2FragmentsData_hero.serializer) + ..add(GHeroWith2FragmentsVars.serializer) + ..add(GHeroWithFragments.serializer) + ..add(GHeroWithFragmentsData.serializer) + ..add(GHeroWithFragmentsData_hero.serializer) + ..add(GHeroWithFragmentsData_hero_friendsConnection.serializer) + ..add(GHeroWithFragmentsData_hero_friendsConnection_edges.serializer) + ..add(GHeroWithFragmentsData_hero_friendsConnection_edges_node.serializer) + ..add(GHeroWithFragmentsVars.serializer) + ..add(GHeroWithInterfaceSubTypedFragments.serializer) + ..add(GHeroWithInterfaceSubTypedFragmentsData.serializer) + ..add(GHeroWithInterfaceSubTypedFragmentsData_hero.serializer) + ..add(GHeroWithInterfaceSubTypedFragmentsVars.serializer) + ..add(GHumanWithArgs.serializer) + ..add(GHumanWithArgsData.serializer) + ..add(GHumanWithArgsData_human.serializer) + ..add(GHumanWithArgsVars.serializer) + ..add(GISODate.serializer) + ..add(GJson.serializer) + ..add(GLengthUnit.serializer) + ..add(GPostFavoritesInput.serializer) + ..add(GPostFragmentData.serializer) + ..add(GPostFragmentData_isFavorited.serializer) + ..add(GPostFragmentData_isLiked.serializer) + ..add(GPostFragmentForUser1Data.serializer) + ..add(GPostFragmentForUser1Data_favoritedUsers.serializer) + ..add(GPostFragmentForUser1Vars.serializer) + ..add(GPostFragmentVars.serializer) + ..add(GPostLikesInput.serializer) + ..add(GPosts.serializer) + ..add(GPostsData.serializer) + ..add(GPostsData_posts.serializer) + ..add(GPostsData_posts_isFavorited.serializer) + ..add(GPostsData_posts_isLiked.serializer) + ..add(GPostsVars.serializer) + ..add(GPostsWithFixedVariable.serializer) + ..add(GPostsWithFixedVariableData.serializer) + ..add(GPostsWithFixedVariableData_posts.serializer) + ..add(GPostsWithFixedVariableData_posts_favoritedUsers.serializer) + ..add(GPostsWithFixedVariableVars.serializer) + ..add(GReviewInput.serializer) + ..add(GReviewWithDate.serializer) + ..add(GReviewWithDateData.serializer) + ..add(GReviewWithDateData_createReview.serializer) + ..add(GReviewWithDateVars.serializer) + ..add(GcomparisonFieldsData.serializer) + ..add(GcomparisonFieldsData_friendsConnection.serializer) + ..add(GcomparisonFieldsData_friendsConnection_edges.serializer) + ..add(GcomparisonFieldsData_friendsConnection_edges_node.serializer) + ..add(GcomparisonFieldsVars.serializer) + ..add(GdroidFieldsFragmentData.serializer) + ..add(GdroidFieldsFragmentVars.serializer) + ..add(GheroDataData.serializer) + ..add(GheroDataVars.serializer) + ..add(GheroFieldsFragmentData__asDroid.serializer) + ..add(GheroFieldsFragmentData__asHuman.serializer) + ..add(GheroFieldsFragmentData__asHuman_friends__asDroid.serializer) + ..add(GheroFieldsFragmentData__asHuman_friends__asHuman.serializer) + ..add(GheroFieldsFragmentData__asHuman_friends__base.serializer) + ..add(GheroFieldsFragmentData__base.serializer) + ..add(GheroFieldsFragmentVars.serializer) + ..add(GheroIdData.serializer) + ..add(GheroIdVars.serializer) + ..add(GheroNameData.serializer) + ..add(GheroNameVars.serializer) + ..add(GhumanFieldsFragmentData.serializer) + ..add(GhumanFieldsFragmentData_friends__asDroid.serializer) + ..add(GhumanFieldsFragmentData_friends__asHuman.serializer) + ..add(GhumanFieldsFragmentData_friends__base.serializer) + ..add(GhumanFieldsFragmentVars.serializer) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(DateTime)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType(CustomField)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType.nullable(GEpisode)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [const FullType.nullable(GEpisode)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [ + const FullType.nullable(GHeroForEpisodeData_hero__asDroid_friends) + ]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [ + const FullType.nullable(GHeroForEpisodeData_hero__base_friends) + ]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [ + const FullType.nullable( + GHeroWithFragmentsData_hero_friendsConnection_edges) + ]), + () => new ListBuilder< + GHeroWithFragmentsData_hero_friendsConnection_edges?>()) + ..addBuilderFactory( + const FullType( + BuiltList, const [const FullType.nullable(GPostsData_posts)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [ + const FullType.nullable(GPostsWithFixedVariableData_posts) + ]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [ + const FullType.nullable( + GcomparisonFieldsData_friendsConnection_edges) + ]), + () => + new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [ + const FullType.nullable(GheroFieldsFragmentData__asHuman_friends) + ]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, const [ + const FullType.nullable(GhumanFieldsFragmentData_friends) + ]), + () => new ListBuilder())) + .build(); + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/graphql/schema.graphql b/codegen/end_to_end_test_tristate/lib/graphql/schema.graphql new file mode 100644 index 00000000..671605a7 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/graphql/schema.graphql @@ -0,0 +1,213 @@ +# Schema borrowed from https://github.com/apollographql/starwars-server + +schema { + query: Query + mutation: Mutation + subscription: Subscription +} + +directive @extends on OBJECT | INTERFACE + + +# The query type, represents all of the entry points into our object graph +type Query { + hero(episode: Episode): Character + reviews(episode: Episode!): [Review] + search(text: String): [SearchResult] + character(id: ID!): Character + droid(id: ID!): Droid + human(id: ID!): Human + starship(id: ID!): Starship + posts(userId: ID!, filter: Json): [Post] +} + +# The mutation type, represents all updates we can make to our data +type Mutation { + createReview(episode: Episode, review: ReviewInput!, createdAt: Date): Review + createCustomField(input: CustomFieldInput!): CustomField +} + +# The subscription type, represents all subscriptions we can make to our data +type Subscription { + reviewAdded(episode: Episode): Review +} + +# The episodes in the Star Wars trilogy +enum Episode { + # Star Wars Episode IV: A New Hope, released in 1977. + NEWHOPE + # Star Wars Episode V: The Empire Strikes Back, released in 1980. + EMPIRE + # Star Wars Episode VI: Return of the Jedi, released in 1983. + JEDI +} + +# A character from the Star Wars universe +interface Character { + # The ID of the character + id: ID! + # The name of the character + name: String! + # The friends of the character, or an empty list if they have none + friends: [Character] + # The friends of the character exposed as a connection with edges + friendsConnection(first: Int, after: ID): FriendsConnection! + # The movies this character appears in + appearsIn: [Episode]! +} + +# Units of height +enum LengthUnit { + # The standard unit around the world + METER + # Primarily used in the United States + FOOT +} + +# A humanoid creature from the Star Wars universe +type Human implements Character { + # The ID of the human + id: ID! + # What this human calls themselves + name: String! + # The home planet of the human, or null if unknown + homePlanet: String + # Height in the preferred unit, default is meters + height(unit: LengthUnit = METER): Float + # Mass in kilograms, or null if unknown + mass: Float + # This human's friends, or an empty list if they have none + friends: [Character] + # The friends of the human exposed as a connection with edges + friendsConnection(first: Int, after: ID): FriendsConnection! + # The movies this human appears in + appearsIn: [Episode]! + # A list of starships this person has piloted, or an empty list if none + starships: [Starship] + # This person's birth date + birthday: Date! +} + +# An autonomous mechanical character in the Star Wars universe +type Droid implements Character { + # The ID of the droid + id: ID! + # What others call this droid + name: String! + # This droid's friends, or an empty list if they have none + friends: [Character] + # The friends of the droid exposed as a connection with edges + friendsConnection(first: Int, after: ID): FriendsConnection! + # The movies this droid appears in + appearsIn: [Episode]! + # This droid's primary function + primaryFunction: String +} + +# A connection object for a character's friends +type FriendsConnection { + # The total number of friends + totalCount: Int + # The edges for each of the character's friends. + edges: [FriendsEdge] + # A list of the friends, as a convenience when edges are not needed. + friends: [Character] + # Information for paginating this connection + pageInfo: PageInfo! +} + +# An edge object for a character's friends +type FriendsEdge { + # A cursor used for pagination + cursor: ID! + # The character represented by this friendship edge + node: Character +} + +# Information for paginating this connection +type PageInfo { + startCursor: ID + endCursor: ID + hasNextPage: Boolean! +} + +# Represents a review for a movie +type Review { + # The movie + episode: Episode + # The number of stars this review gave, 1-5 + stars: Int! + # Comment about the movie + commentary: String + # Date review created + createdAt: Date + # Date episode seen + seenOn: [Date!]! + # A custom field + custom: [CustomField!]! +} + +# The input object sent when someone is creating a new review +input ReviewInput { + # 0-5 stars + stars: Int! + # Comment about the movie, optional + commentary: String + # Favorite color, optional + favorite_color: ColorInput + # Date viewed + seenOn: [Date] +} + +input CustomFieldInput { + id: ID! + customField: CustomField +} + +# The input object sent when passing in a color +input ColorInput { + red: Int! + green: Int! + blue: Int! +} + +type Starship { + # The ID of the starship + id: ID! + # The name of the starship + name: String! + # Length of the starship, along the longest axis + length(unit: LengthUnit = METER): Float + coordinates: [[Float!]!] +} + +type Post { + id: ID! + body: String! + favoritedUsers(where: PostLikesInput, filter: Json): PostLikes + likedUsers(where: PostFavoritesInput): PostFavorites +} + +type PostLikes { + totalCount: Int! +} + +type PostFavorites { + totalCount: Int! +} + +input PostLikesInput { + id: ID! +} + +input PostFavoritesInput { + id: ID! +} + +union SearchResult = Human | Droid | Starship + +scalar Date +scalar ISODate +scalar CustomField + +scalar Json diff --git a/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.ast.gql.dart b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.ast.gql.dart new file mode 100644 index 00000000..a893989e --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.ast.gql.dart @@ -0,0 +1,95 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const DroidFragment = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'DroidFragment'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Droid'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'primaryFunction'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), +); +const HeroForEpisode = _i1.OperationDefinitionNode( + type: _i1.OperationType.query, + name: _i1.NameNode(value: 'HeroForEpisode'), + variableDefinitions: [ + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'ep')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Episode'), + isNonNull: true, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'hero'), + alias: null, + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'episode'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'ep')), + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'friends'), + alias: null, + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), + ), + _i1.InlineFragmentNode( + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Droid'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'DroidFragment'), + directives: [], + ) + ]), + ), + ]), + ) + ]), +); +const document = _i1.DocumentNode(definitions: [ + DroidFragment, + HeroForEpisode, +]); diff --git a/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.data.gql.dart b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.data.gql.dart new file mode 100644 index 00000000..655d9736 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.data.gql.dart @@ -0,0 +1,290 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; +import 'package:gql_code_builder/src/serializers/inline_fragment_serializer.dart' + as _i2; + +part 'hero_for_episode.data.gql.g.dart'; + +abstract class GHeroForEpisodeData + implements Built { + GHeroForEpisodeData._(); + + factory GHeroForEpisodeData( + [Function(GHeroForEpisodeDataBuilder b) updates]) = _$GHeroForEpisodeData; + + static void _initializeBuilder(GHeroForEpisodeDataBuilder b) => + b..G__typename = 'Query'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + GHeroForEpisodeData_hero? get hero; + static Serializer get serializer => + _$gHeroForEpisodeDataSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GHeroForEpisodeData.serializer, + this, + ) as Map); + + static GHeroForEpisodeData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GHeroForEpisodeData.serializer, + json, + ); +} + +abstract class GHeroForEpisodeData_hero { + @BuiltValueField(wireName: '__typename') + String get G__typename; + String get name; + BuiltList? get friends; + static Serializer get serializer => + _i2.InlineFragmentSerializer( + 'GHeroForEpisodeData_hero', + GHeroForEpisodeData_hero__base, + {'Droid': GHeroForEpisodeData_hero__asDroid}, + ); + + Map toJson() => (_i1.serializers.serializeWith( + GHeroForEpisodeData_hero.serializer, + this, + ) as Map); + + static GHeroForEpisodeData_hero? fromJson(Map json) => + _i1.serializers.deserializeWith( + GHeroForEpisodeData_hero.serializer, + json, + ); +} + +extension GHeroForEpisodeData_heroWhenExtension on GHeroForEpisodeData_hero { + _T when<_T>({ + required _T Function(GHeroForEpisodeData_hero__asDroid) droid, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Droid': + return droid((this as GHeroForEpisodeData_hero__asDroid)); + default: + return orElse(); + } + } + + _T maybeWhen<_T>({ + _T Function(GHeroForEpisodeData_hero__asDroid)? droid, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'Droid': + return droid != null + ? droid((this as GHeroForEpisodeData_hero__asDroid)) + : orElse(); + default: + return orElse(); + } + } +} + +abstract class GHeroForEpisodeData_hero__base + implements + Built, + GHeroForEpisodeData_hero { + GHeroForEpisodeData_hero__base._(); + + factory GHeroForEpisodeData_hero__base( + [Function(GHeroForEpisodeData_hero__baseBuilder b) updates]) = + _$GHeroForEpisodeData_hero__base; + + static void _initializeBuilder(GHeroForEpisodeData_hero__baseBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get name; + @override + BuiltList? get friends; + static Serializer get serializer => + _$gHeroForEpisodeDataHeroBaseSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GHeroForEpisodeData_hero__base.serializer, + this, + ) as Map); + + static GHeroForEpisodeData_hero__base? fromJson(Map json) => + _i1.serializers.deserializeWith( + GHeroForEpisodeData_hero__base.serializer, + json, + ); +} + +abstract class GHeroForEpisodeData_hero__base_friends + implements + Built, + GHeroForEpisodeData_hero_friends { + GHeroForEpisodeData_hero__base_friends._(); + + factory GHeroForEpisodeData_hero__base_friends( + [Function(GHeroForEpisodeData_hero__base_friendsBuilder b) updates]) = + _$GHeroForEpisodeData_hero__base_friends; + + static void _initializeBuilder( + GHeroForEpisodeData_hero__base_friendsBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get name; + static Serializer get serializer => + _$gHeroForEpisodeDataHeroBaseFriendsSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GHeroForEpisodeData_hero__base_friends.serializer, + this, + ) as Map); + + static GHeroForEpisodeData_hero__base_friends? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GHeroForEpisodeData_hero__base_friends.serializer, + json, + ); +} + +abstract class GHeroForEpisodeData_hero__asDroid + implements + Built, + GHeroForEpisodeData_hero, + GDroidFragment { + GHeroForEpisodeData_hero__asDroid._(); + + factory GHeroForEpisodeData_hero__asDroid( + [Function(GHeroForEpisodeData_hero__asDroidBuilder b) updates]) = + _$GHeroForEpisodeData_hero__asDroid; + + static void _initializeBuilder(GHeroForEpisodeData_hero__asDroidBuilder b) => + b..G__typename = 'Droid'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get name; + @override + BuiltList? get friends; + @override + String? get primaryFunction; + static Serializer get serializer => + _$gHeroForEpisodeDataHeroAsDroidSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GHeroForEpisodeData_hero__asDroid.serializer, + this, + ) as Map); + + static GHeroForEpisodeData_hero__asDroid? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GHeroForEpisodeData_hero__asDroid.serializer, + json, + ); +} + +abstract class GHeroForEpisodeData_hero__asDroid_friends + implements + Built, + GHeroForEpisodeData_hero_friends { + GHeroForEpisodeData_hero__asDroid_friends._(); + + factory GHeroForEpisodeData_hero__asDroid_friends( + [Function(GHeroForEpisodeData_hero__asDroid_friendsBuilder b) + updates]) = _$GHeroForEpisodeData_hero__asDroid_friends; + + static void _initializeBuilder( + GHeroForEpisodeData_hero__asDroid_friendsBuilder b) => + b..G__typename = 'Character'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get name; + static Serializer get serializer => + _$gHeroForEpisodeDataHeroAsDroidFriendsSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GHeroForEpisodeData_hero__asDroid_friends.serializer, + this, + ) as Map); + + static GHeroForEpisodeData_hero__asDroid_friends? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GHeroForEpisodeData_hero__asDroid_friends.serializer, + json, + ); +} + +abstract class GHeroForEpisodeData_hero_friends { + String get G__typename; + String get name; + Map toJson(); +} + +abstract class GDroidFragment { + String get G__typename; + String? get primaryFunction; + Map toJson(); +} + +abstract class GDroidFragmentData + implements + Built, + GDroidFragment { + GDroidFragmentData._(); + + factory GDroidFragmentData([Function(GDroidFragmentDataBuilder b) updates]) = + _$GDroidFragmentData; + + static void _initializeBuilder(GDroidFragmentDataBuilder b) => + b..G__typename = 'Droid'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String? get primaryFunction; + static Serializer get serializer => + _$gDroidFragmentDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GDroidFragmentData.serializer, + this, + ) as Map); + + static GDroidFragmentData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GDroidFragmentData.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.data.gql.g.dart b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.data.gql.g.dart new file mode 100644 index 00000000..ee58bc38 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.data.gql.g.dart @@ -0,0 +1,1110 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'hero_for_episode.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gHeroForEpisodeDataSerializer = + new _$GHeroForEpisodeDataSerializer(); +Serializer + _$gHeroForEpisodeDataHeroBaseSerializer = + new _$GHeroForEpisodeData_hero__baseSerializer(); +Serializer + _$gHeroForEpisodeDataHeroBaseFriendsSerializer = + new _$GHeroForEpisodeData_hero__base_friendsSerializer(); +Serializer + _$gHeroForEpisodeDataHeroAsDroidSerializer = + new _$GHeroForEpisodeData_hero__asDroidSerializer(); +Serializer + _$gHeroForEpisodeDataHeroAsDroidFriendsSerializer = + new _$GHeroForEpisodeData_hero__asDroid_friendsSerializer(); +Serializer _$gDroidFragmentDataSerializer = + new _$GDroidFragmentDataSerializer(); + +class _$GHeroForEpisodeDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroForEpisodeData, + _$GHeroForEpisodeData + ]; + @override + final String wireName = 'GHeroForEpisodeData'; + + @override + Iterable serialize( + Serializers serializers, GHeroForEpisodeData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.hero; + if (value != null) { + result + ..add('hero') + ..add(serializers.serialize(value, + specifiedType: const FullType(GHeroForEpisodeData_hero))); + } + return result; + } + + @override + GHeroForEpisodeData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroForEpisodeDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'hero': + result.hero = serializers.deserialize(value, + specifiedType: const FullType(GHeroForEpisodeData_hero)) + as GHeroForEpisodeData_hero?; + break; + } + } + + return result.build(); + } +} + +class _$GHeroForEpisodeData_hero__baseSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroForEpisodeData_hero__base, + _$GHeroForEpisodeData_hero__base + ]; + @override + final String wireName = 'GHeroForEpisodeData_hero__base'; + + @override + Iterable serialize( + Serializers serializers, GHeroForEpisodeData_hero__base object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.friends; + if (value != null) { + result + ..add('friends') + ..add(serializers.serialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable(GHeroForEpisodeData_hero__base_friends) + ]))); + } + return result; + } + + @override + GHeroForEpisodeData_hero__base deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroForEpisodeData_hero__baseBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'friends': + result.friends.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable(GHeroForEpisodeData_hero__base_friends) + ]))! as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$GHeroForEpisodeData_hero__base_friendsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroForEpisodeData_hero__base_friends, + _$GHeroForEpisodeData_hero__base_friends + ]; + @override + final String wireName = 'GHeroForEpisodeData_hero__base_friends'; + + @override + Iterable serialize( + Serializers serializers, GHeroForEpisodeData_hero__base_friends object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GHeroForEpisodeData_hero__base_friends deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroForEpisodeData_hero__base_friendsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GHeroForEpisodeData_hero__asDroidSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroForEpisodeData_hero__asDroid, + _$GHeroForEpisodeData_hero__asDroid + ]; + @override + final String wireName = 'GHeroForEpisodeData_hero__asDroid'; + + @override + Iterable serialize( + Serializers serializers, GHeroForEpisodeData_hero__asDroid object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.friends; + if (value != null) { + result + ..add('friends') + ..add(serializers.serialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable(GHeroForEpisodeData_hero__asDroid_friends) + ]))); + } + value = object.primaryFunction; + if (value != null) { + result + ..add('primaryFunction') + ..add(serializers.serialize(value, + specifiedType: const FullType(String))); + } + return result; + } + + @override + GHeroForEpisodeData_hero__asDroid deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroForEpisodeData_hero__asDroidBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'friends': + result.friends.replace(serializers.deserialize(value, + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable( + GHeroForEpisodeData_hero__asDroid_friends) + ]))! as BuiltList); + break; + case 'primaryFunction': + result.primaryFunction = serializers.deserialize(value, + specifiedType: const FullType(String)) as String?; + break; + } + } + + return result.build(); + } +} + +class _$GHeroForEpisodeData_hero__asDroid_friendsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroForEpisodeData_hero__asDroid_friends, + _$GHeroForEpisodeData_hero__asDroid_friends + ]; + @override + final String wireName = 'GHeroForEpisodeData_hero__asDroid_friends'; + + @override + Iterable serialize( + Serializers serializers, GHeroForEpisodeData_hero__asDroid_friends object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GHeroForEpisodeData_hero__asDroid_friends deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroForEpisodeData_hero__asDroid_friendsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GDroidFragmentDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GDroidFragmentData, _$GDroidFragmentData]; + @override + final String wireName = 'GDroidFragmentData'; + + @override + Iterable serialize( + Serializers serializers, GDroidFragmentData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.primaryFunction; + if (value != null) { + result + ..add('primaryFunction') + ..add(serializers.serialize(value, + specifiedType: const FullType(String))); + } + return result; + } + + @override + GDroidFragmentData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GDroidFragmentDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'primaryFunction': + result.primaryFunction = serializers.deserialize(value, + specifiedType: const FullType(String)) as String?; + break; + } + } + + return result.build(); + } +} + +class _$GHeroForEpisodeData extends GHeroForEpisodeData { + @override + final String G__typename; + @override + final GHeroForEpisodeData_hero? hero; + + factory _$GHeroForEpisodeData( + [void Function(GHeroForEpisodeDataBuilder)? updates]) => + (new GHeroForEpisodeDataBuilder()..update(updates))._build(); + + _$GHeroForEpisodeData._({required this.G__typename, this.hero}) : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroForEpisodeData', 'G__typename'); + } + + @override + GHeroForEpisodeData rebuild( + void Function(GHeroForEpisodeDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroForEpisodeDataBuilder toBuilder() => + new GHeroForEpisodeDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroForEpisodeData && + G__typename == other.G__typename && + hero == other.hero; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, hero.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroForEpisodeData') + ..add('G__typename', G__typename) + ..add('hero', hero)) + .toString(); + } +} + +class GHeroForEpisodeDataBuilder + implements Builder { + _$GHeroForEpisodeData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GHeroForEpisodeData_hero? _hero; + GHeroForEpisodeData_hero? get hero => _$this._hero; + set hero(GHeroForEpisodeData_hero? hero) => _$this._hero = hero; + + GHeroForEpisodeDataBuilder() { + GHeroForEpisodeData._initializeBuilder(this); + } + + GHeroForEpisodeDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _hero = $v.hero; + _$v = null; + } + return this; + } + + @override + void replace(GHeroForEpisodeData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroForEpisodeData; + } + + @override + void update(void Function(GHeroForEpisodeDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroForEpisodeData build() => _build(); + + _$GHeroForEpisodeData _build() { + final _$result = _$v ?? + new _$GHeroForEpisodeData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroForEpisodeData', 'G__typename'), + hero: hero); + replace(_$result); + return _$result; + } +} + +class _$GHeroForEpisodeData_hero__base extends GHeroForEpisodeData_hero__base { + @override + final String G__typename; + @override + final String name; + @override + final BuiltList? friends; + + factory _$GHeroForEpisodeData_hero__base( + [void Function(GHeroForEpisodeData_hero__baseBuilder)? updates]) => + (new GHeroForEpisodeData_hero__baseBuilder()..update(updates))._build(); + + _$GHeroForEpisodeData_hero__base._( + {required this.G__typename, required this.name, this.friends}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroForEpisodeData_hero__base', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + name, r'GHeroForEpisodeData_hero__base', 'name'); + } + + @override + GHeroForEpisodeData_hero__base rebuild( + void Function(GHeroForEpisodeData_hero__baseBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroForEpisodeData_hero__baseBuilder toBuilder() => + new GHeroForEpisodeData_hero__baseBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroForEpisodeData_hero__base && + G__typename == other.G__typename && + name == other.name && + friends == other.friends; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, friends.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroForEpisodeData_hero__base') + ..add('G__typename', G__typename) + ..add('name', name) + ..add('friends', friends)) + .toString(); + } +} + +class GHeroForEpisodeData_hero__baseBuilder + implements + Builder { + _$GHeroForEpisodeData_hero__base? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + ListBuilder? _friends; + ListBuilder get friends => + _$this._friends ??= + new ListBuilder(); + set friends(ListBuilder? friends) => + _$this._friends = friends; + + GHeroForEpisodeData_hero__baseBuilder() { + GHeroForEpisodeData_hero__base._initializeBuilder(this); + } + + GHeroForEpisodeData_hero__baseBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _name = $v.name; + _friends = $v.friends?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GHeroForEpisodeData_hero__base other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroForEpisodeData_hero__base; + } + + @override + void update(void Function(GHeroForEpisodeData_hero__baseBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroForEpisodeData_hero__base build() => _build(); + + _$GHeroForEpisodeData_hero__base _build() { + _$GHeroForEpisodeData_hero__base _$result; + try { + _$result = _$v ?? + new _$GHeroForEpisodeData_hero__base._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GHeroForEpisodeData_hero__base', 'G__typename'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GHeroForEpisodeData_hero__base', 'name'), + friends: _friends?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'friends'; + _friends?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroForEpisodeData_hero__base', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GHeroForEpisodeData_hero__base_friends + extends GHeroForEpisodeData_hero__base_friends { + @override + final String G__typename; + @override + final String name; + + factory _$GHeroForEpisodeData_hero__base_friends( + [void Function(GHeroForEpisodeData_hero__base_friendsBuilder)? + updates]) => + (new GHeroForEpisodeData_hero__base_friendsBuilder()..update(updates)) + ._build(); + + _$GHeroForEpisodeData_hero__base_friends._( + {required this.G__typename, required this.name}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroForEpisodeData_hero__base_friends', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + name, r'GHeroForEpisodeData_hero__base_friends', 'name'); + } + + @override + GHeroForEpisodeData_hero__base_friends rebuild( + void Function(GHeroForEpisodeData_hero__base_friendsBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroForEpisodeData_hero__base_friendsBuilder toBuilder() => + new GHeroForEpisodeData_hero__base_friendsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroForEpisodeData_hero__base_friends && + G__typename == other.G__typename && + name == other.name; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GHeroForEpisodeData_hero__base_friends') + ..add('G__typename', G__typename) + ..add('name', name)) + .toString(); + } +} + +class GHeroForEpisodeData_hero__base_friendsBuilder + implements + Builder { + _$GHeroForEpisodeData_hero__base_friends? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + GHeroForEpisodeData_hero__base_friendsBuilder() { + GHeroForEpisodeData_hero__base_friends._initializeBuilder(this); + } + + GHeroForEpisodeData_hero__base_friendsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _name = $v.name; + _$v = null; + } + return this; + } + + @override + void replace(GHeroForEpisodeData_hero__base_friends other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroForEpisodeData_hero__base_friends; + } + + @override + void update( + void Function(GHeroForEpisodeData_hero__base_friendsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroForEpisodeData_hero__base_friends build() => _build(); + + _$GHeroForEpisodeData_hero__base_friends _build() { + final _$result = _$v ?? + new _$GHeroForEpisodeData_hero__base_friends._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GHeroForEpisodeData_hero__base_friends', 'G__typename'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GHeroForEpisodeData_hero__base_friends', 'name')); + replace(_$result); + return _$result; + } +} + +class _$GHeroForEpisodeData_hero__asDroid + extends GHeroForEpisodeData_hero__asDroid { + @override + final String G__typename; + @override + final String name; + @override + final BuiltList? friends; + @override + final String? primaryFunction; + + factory _$GHeroForEpisodeData_hero__asDroid( + [void Function(GHeroForEpisodeData_hero__asDroidBuilder)? updates]) => + (new GHeroForEpisodeData_hero__asDroidBuilder()..update(updates)) + ._build(); + + _$GHeroForEpisodeData_hero__asDroid._( + {required this.G__typename, + required this.name, + this.friends, + this.primaryFunction}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroForEpisodeData_hero__asDroid', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + name, r'GHeroForEpisodeData_hero__asDroid', 'name'); + } + + @override + GHeroForEpisodeData_hero__asDroid rebuild( + void Function(GHeroForEpisodeData_hero__asDroidBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroForEpisodeData_hero__asDroidBuilder toBuilder() => + new GHeroForEpisodeData_hero__asDroidBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroForEpisodeData_hero__asDroid && + G__typename == other.G__typename && + name == other.name && + friends == other.friends && + primaryFunction == other.primaryFunction; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, friends.hashCode); + _$hash = $jc(_$hash, primaryFunction.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroForEpisodeData_hero__asDroid') + ..add('G__typename', G__typename) + ..add('name', name) + ..add('friends', friends) + ..add('primaryFunction', primaryFunction)) + .toString(); + } +} + +class GHeroForEpisodeData_hero__asDroidBuilder + implements + Builder { + _$GHeroForEpisodeData_hero__asDroid? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + ListBuilder? _friends; + ListBuilder get friends => + _$this._friends ??= + new ListBuilder(); + set friends( + ListBuilder? friends) => + _$this._friends = friends; + + String? _primaryFunction; + String? get primaryFunction => _$this._primaryFunction; + set primaryFunction(String? primaryFunction) => + _$this._primaryFunction = primaryFunction; + + GHeroForEpisodeData_hero__asDroidBuilder() { + GHeroForEpisodeData_hero__asDroid._initializeBuilder(this); + } + + GHeroForEpisodeData_hero__asDroidBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _name = $v.name; + _friends = $v.friends?.toBuilder(); + _primaryFunction = $v.primaryFunction; + _$v = null; + } + return this; + } + + @override + void replace(GHeroForEpisodeData_hero__asDroid other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroForEpisodeData_hero__asDroid; + } + + @override + void update( + void Function(GHeroForEpisodeData_hero__asDroidBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroForEpisodeData_hero__asDroid build() => _build(); + + _$GHeroForEpisodeData_hero__asDroid _build() { + _$GHeroForEpisodeData_hero__asDroid _$result; + try { + _$result = _$v ?? + new _$GHeroForEpisodeData_hero__asDroid._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GHeroForEpisodeData_hero__asDroid', 'G__typename'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GHeroForEpisodeData_hero__asDroid', 'name'), + friends: _friends?.build(), + primaryFunction: primaryFunction); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'friends'; + _friends?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroForEpisodeData_hero__asDroid', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GHeroForEpisodeData_hero__asDroid_friends + extends GHeroForEpisodeData_hero__asDroid_friends { + @override + final String G__typename; + @override + final String name; + + factory _$GHeroForEpisodeData_hero__asDroid_friends( + [void Function(GHeroForEpisodeData_hero__asDroid_friendsBuilder)? + updates]) => + (new GHeroForEpisodeData_hero__asDroid_friendsBuilder()..update(updates)) + ._build(); + + _$GHeroForEpisodeData_hero__asDroid_friends._( + {required this.G__typename, required this.name}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GHeroForEpisodeData_hero__asDroid_friends', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + name, r'GHeroForEpisodeData_hero__asDroid_friends', 'name'); + } + + @override + GHeroForEpisodeData_hero__asDroid_friends rebuild( + void Function(GHeroForEpisodeData_hero__asDroid_friendsBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroForEpisodeData_hero__asDroid_friendsBuilder toBuilder() => + new GHeroForEpisodeData_hero__asDroid_friendsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroForEpisodeData_hero__asDroid_friends && + G__typename == other.G__typename && + name == other.name; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper( + r'GHeroForEpisodeData_hero__asDroid_friends') + ..add('G__typename', G__typename) + ..add('name', name)) + .toString(); + } +} + +class GHeroForEpisodeData_hero__asDroid_friendsBuilder + implements + Builder { + _$GHeroForEpisodeData_hero__asDroid_friends? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + GHeroForEpisodeData_hero__asDroid_friendsBuilder() { + GHeroForEpisodeData_hero__asDroid_friends._initializeBuilder(this); + } + + GHeroForEpisodeData_hero__asDroid_friendsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _name = $v.name; + _$v = null; + } + return this; + } + + @override + void replace(GHeroForEpisodeData_hero__asDroid_friends other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroForEpisodeData_hero__asDroid_friends; + } + + @override + void update( + void Function(GHeroForEpisodeData_hero__asDroid_friendsBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GHeroForEpisodeData_hero__asDroid_friends build() => _build(); + + _$GHeroForEpisodeData_hero__asDroid_friends _build() { + final _$result = _$v ?? + new _$GHeroForEpisodeData_hero__asDroid_friends._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GHeroForEpisodeData_hero__asDroid_friends', 'G__typename'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GHeroForEpisodeData_hero__asDroid_friends', 'name')); + replace(_$result); + return _$result; + } +} + +class _$GDroidFragmentData extends GDroidFragmentData { + @override + final String G__typename; + @override + final String? primaryFunction; + + factory _$GDroidFragmentData( + [void Function(GDroidFragmentDataBuilder)? updates]) => + (new GDroidFragmentDataBuilder()..update(updates))._build(); + + _$GDroidFragmentData._({required this.G__typename, this.primaryFunction}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GDroidFragmentData', 'G__typename'); + } + + @override + GDroidFragmentData rebuild( + void Function(GDroidFragmentDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GDroidFragmentDataBuilder toBuilder() => + new GDroidFragmentDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GDroidFragmentData && + G__typename == other.G__typename && + primaryFunction == other.primaryFunction; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, primaryFunction.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GDroidFragmentData') + ..add('G__typename', G__typename) + ..add('primaryFunction', primaryFunction)) + .toString(); + } +} + +class GDroidFragmentDataBuilder + implements Builder { + _$GDroidFragmentData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _primaryFunction; + String? get primaryFunction => _$this._primaryFunction; + set primaryFunction(String? primaryFunction) => + _$this._primaryFunction = primaryFunction; + + GDroidFragmentDataBuilder() { + GDroidFragmentData._initializeBuilder(this); + } + + GDroidFragmentDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _primaryFunction = $v.primaryFunction; + _$v = null; + } + return this; + } + + @override + void replace(GDroidFragmentData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GDroidFragmentData; + } + + @override + void update(void Function(GDroidFragmentDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GDroidFragmentData build() => _build(); + + _$GDroidFragmentData _build() { + final _$result = _$v ?? + new _$GDroidFragmentData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GDroidFragmentData', 'G__typename'), + primaryFunction: primaryFunction); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.req.gql.dart b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.req.gql.dart new file mode 100644 index 00000000..87df0316 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.req.gql.dart @@ -0,0 +1,45 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:end_to_end_test_tristate/interfaces/__generated__/hero_for_episode.ast.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/interfaces/__generated__/hero_for_episode.var.gql.dart' + as _i3; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'hero_for_episode.req.gql.g.dart'; + +abstract class GHeroForEpisode + implements Built { + GHeroForEpisode._(); + + factory GHeroForEpisode([Function(GHeroForEpisodeBuilder b) updates]) = + _$GHeroForEpisode; + + static void _initializeBuilder(GHeroForEpisodeBuilder b) => b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'HeroForEpisode', + ); + + _i3.GHeroForEpisodeVars get vars; + _i1.Operation get operation; + static Serializer get serializer => + _$gHeroForEpisodeSerializer; + + Map toJson() => (_i4.serializers.serializeWith( + GHeroForEpisode.serializer, + this, + ) as Map); + + static GHeroForEpisode? fromJson(Map json) => + _i4.serializers.deserializeWith( + GHeroForEpisode.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.req.gql.g.dart b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.req.gql.g.dart new file mode 100644 index 00000000..fbeddc86 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.req.gql.g.dart @@ -0,0 +1,177 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'hero_for_episode.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gHeroForEpisodeSerializer = + new _$GHeroForEpisodeSerializer(); + +class _$GHeroForEpisodeSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GHeroForEpisode, _$GHeroForEpisode]; + @override + final String wireName = 'GHeroForEpisode'; + + @override + Iterable serialize(Serializers serializers, GHeroForEpisode object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: const FullType(_i3.GHeroForEpisodeVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GHeroForEpisode deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroForEpisodeBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'vars': + result.vars.replace(serializers.deserialize(value, + specifiedType: const FullType(_i3.GHeroForEpisodeVars))! + as _i3.GHeroForEpisodeVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GHeroForEpisode extends GHeroForEpisode { + @override + final _i3.GHeroForEpisodeVars vars; + @override + final _i1.Operation operation; + + factory _$GHeroForEpisode([void Function(GHeroForEpisodeBuilder)? updates]) => + (new GHeroForEpisodeBuilder()..update(updates))._build(); + + _$GHeroForEpisode._({required this.vars, required this.operation}) + : super._() { + BuiltValueNullFieldError.checkNotNull(vars, r'GHeroForEpisode', 'vars'); + BuiltValueNullFieldError.checkNotNull( + operation, r'GHeroForEpisode', 'operation'); + } + + @override + GHeroForEpisode rebuild(void Function(GHeroForEpisodeBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroForEpisodeBuilder toBuilder() => + new GHeroForEpisodeBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroForEpisode && + vars == other.vars && + operation == other.operation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroForEpisode') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GHeroForEpisodeBuilder + implements Builder { + _$GHeroForEpisode? _$v; + + _i3.GHeroForEpisodeVarsBuilder? _vars; + _i3.GHeroForEpisodeVarsBuilder get vars => + _$this._vars ??= new _i3.GHeroForEpisodeVarsBuilder(); + set vars(_i3.GHeroForEpisodeVarsBuilder? vars) => _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GHeroForEpisodeBuilder() { + GHeroForEpisode._initializeBuilder(this); + } + + GHeroForEpisodeBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GHeroForEpisode other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroForEpisode; + } + + @override + void update(void Function(GHeroForEpisodeBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroForEpisode build() => _build(); + + _$GHeroForEpisode _build() { + _$GHeroForEpisode _$result; + try { + _$result = _$v ?? + new _$GHeroForEpisode._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull( + operation, r'GHeroForEpisode', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroForEpisode', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.dart b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.dart new file mode 100644 index 00000000..77934652 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.dart @@ -0,0 +1,126 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart' + as _i1; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i2; + +part 'hero_for_episode.var.gql.g.dart'; + +abstract class GHeroForEpisodeVars + implements Built { + GHeroForEpisodeVars._(); + + factory GHeroForEpisodeVars( + [Function(GHeroForEpisodeVarsBuilder b) updates]) = _$GHeroForEpisodeVars; + + _i1.GEpisode get ep; + Map toJson() => (_i2.serializers.serializeWith( + GHeroForEpisodeVars.serializer, + this, + ) as Map); + + static GHeroForEpisodeVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GHeroForEpisodeVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GHeroForEpisodeVarsSerializer(); +} + +abstract class GDroidFragmentVars + implements Built { + GDroidFragmentVars._(); + + factory GDroidFragmentVars([Function(GDroidFragmentVarsBuilder b) updates]) = + _$GDroidFragmentVars; + + Map toJson() => (_i2.serializers.serializeWith( + GDroidFragmentVars.serializer, + this, + ) as Map); + + static GDroidFragmentVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GDroidFragmentVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GDroidFragmentVarsSerializer(); +} + +class GHeroForEpisodeVarsSerializer + extends StructuredSerializer { + final String wireName = 'GHeroForEpisodeVars'; + + final Iterable types = const [ + GHeroForEpisodeVars, + _$GHeroForEpisodeVars + ]; + + Iterable serialize( + Serializers serializers, + GHeroForEpisodeVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('ep'); + result.add(serializers.serialize(object.ep, + specifiedType: const FullType(_i1.GEpisode))); + return result; + } + + GHeroForEpisodeVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GHeroForEpisodeVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'ep': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; + builder.ep = fieldValue; + break; + } + } + return builder.build(); + } +} + +class GDroidFragmentVarsSerializer + extends StructuredSerializer { + final String wireName = 'GDroidFragmentVars'; + + final Iterable types = const [GDroidFragmentVars, _$GDroidFragmentVars]; + + Iterable serialize( + Serializers serializers, + GDroidFragmentVars object, { + FullType specifiedType = FullType.unspecified, + }) { + return const []; + } + + GDroidFragmentVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + return GDroidFragmentVars(); + } +} diff --git a/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.g.dart b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.g.dart new file mode 100644 index 00000000..5ff1690c --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.g.dart @@ -0,0 +1,154 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'hero_for_episode.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$GHeroForEpisodeVars extends GHeroForEpisodeVars { + @override + final _i1.GEpisode ep; + + factory _$GHeroForEpisodeVars( + [void Function(GHeroForEpisodeVarsBuilder)? updates]) => + (new GHeroForEpisodeVarsBuilder()..update(updates))._build(); + + _$GHeroForEpisodeVars._({required this.ep}) : super._() { + BuiltValueNullFieldError.checkNotNull(ep, r'GHeroForEpisodeVars', 'ep'); + } + + @override + GHeroForEpisodeVars rebuild( + void Function(GHeroForEpisodeVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroForEpisodeVarsBuilder toBuilder() => + new GHeroForEpisodeVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroForEpisodeVars && ep == other.ep; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, ep.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroForEpisodeVars')..add('ep', ep)) + .toString(); + } +} + +class GHeroForEpisodeVarsBuilder + implements Builder { + _$GHeroForEpisodeVars? _$v; + + _i1.GEpisode? _ep; + _i1.GEpisode? get ep => _$this._ep; + set ep(_i1.GEpisode? ep) => _$this._ep = ep; + + GHeroForEpisodeVarsBuilder(); + + GHeroForEpisodeVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _ep = $v.ep; + _$v = null; + } + return this; + } + + @override + void replace(GHeroForEpisodeVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroForEpisodeVars; + } + + @override + void update(void Function(GHeroForEpisodeVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroForEpisodeVars build() => _build(); + + _$GHeroForEpisodeVars _build() { + final _$result = _$v ?? + new _$GHeroForEpisodeVars._( + ep: BuiltValueNullFieldError.checkNotNull( + ep, r'GHeroForEpisodeVars', 'ep')); + replace(_$result); + return _$result; + } +} + +class _$GDroidFragmentVars extends GDroidFragmentVars { + factory _$GDroidFragmentVars( + [void Function(GDroidFragmentVarsBuilder)? updates]) => + (new GDroidFragmentVarsBuilder()..update(updates))._build(); + + _$GDroidFragmentVars._() : super._(); + + @override + GDroidFragmentVars rebuild( + void Function(GDroidFragmentVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GDroidFragmentVarsBuilder toBuilder() => + new GDroidFragmentVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GDroidFragmentVars; + } + + @override + int get hashCode { + return 790625500; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GDroidFragmentVars').toString(); + } +} + +class GDroidFragmentVarsBuilder + implements Builder { + _$GDroidFragmentVars? _$v; + + GDroidFragmentVarsBuilder(); + + @override + void replace(GDroidFragmentVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GDroidFragmentVars; + } + + @override + void update(void Function(GDroidFragmentVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GDroidFragmentVars build() => _build(); + + _$GDroidFragmentVars _build() { + final _$result = _$v ?? new _$GDroidFragmentVars._(); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/interfaces/hero_for_episode.graphql b/codegen/end_to_end_test_tristate/lib/interfaces/hero_for_episode.graphql new file mode 100644 index 00000000..04c8b4ac --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/interfaces/hero_for_episode.graphql @@ -0,0 +1,15 @@ +fragment DroidFragment on Droid { + primaryFunction +} + +query HeroForEpisode($ep: Episode!) { + hero(episode: $ep) { + name + friends { + name + } + ... on Droid { + ...DroidFragment + } + } +} diff --git a/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.ast.gql.dart b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.ast.gql.dart new file mode 100644 index 00000000..fc7464d7 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.ast.gql.dart @@ -0,0 +1,37 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const HeroNoVars = _i1.OperationDefinitionNode( + type: _i1.OperationType.query, + name: _i1.NameNode(value: 'HeroNoVars'), + variableDefinitions: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'hero'), + alias: null, + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ) + ]), +); +const document = _i1.DocumentNode(definitions: [HeroNoVars]); diff --git a/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.data.gql.dart b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.data.gql.dart new file mode 100644 index 00000000..797e9c1c --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.data.gql.dart @@ -0,0 +1,68 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'hero_no_vars.data.gql.g.dart'; + +abstract class GHeroNoVarsData + implements Built { + GHeroNoVarsData._(); + + factory GHeroNoVarsData([Function(GHeroNoVarsDataBuilder b) updates]) = + _$GHeroNoVarsData; + + static void _initializeBuilder(GHeroNoVarsDataBuilder b) => + b..G__typename = 'Query'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + GHeroNoVarsData_hero? get hero; + static Serializer get serializer => + _$gHeroNoVarsDataSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GHeroNoVarsData.serializer, + this, + ) as Map); + + static GHeroNoVarsData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GHeroNoVarsData.serializer, + json, + ); +} + +abstract class GHeroNoVarsData_hero + implements Built { + GHeroNoVarsData_hero._(); + + factory GHeroNoVarsData_hero( + [Function(GHeroNoVarsData_heroBuilder b) updates]) = + _$GHeroNoVarsData_hero; + + static void _initializeBuilder(GHeroNoVarsData_heroBuilder b) => + b..G__typename = 'Character'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + String get id; + String get name; + static Serializer get serializer => + _$gHeroNoVarsDataHeroSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GHeroNoVarsData_hero.serializer, + this, + ) as Map); + + static GHeroNoVarsData_hero? fromJson(Map json) => + _i1.serializers.deserializeWith( + GHeroNoVarsData_hero.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.data.gql.g.dart b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.data.gql.g.dart new file mode 100644 index 00000000..849ff651 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.data.gql.g.dart @@ -0,0 +1,358 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'hero_no_vars.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gHeroNoVarsDataSerializer = + new _$GHeroNoVarsDataSerializer(); +Serializer _$gHeroNoVarsDataHeroSerializer = + new _$GHeroNoVarsData_heroSerializer(); + +class _$GHeroNoVarsDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GHeroNoVarsData, _$GHeroNoVarsData]; + @override + final String wireName = 'GHeroNoVarsData'; + + @override + Iterable serialize(Serializers serializers, GHeroNoVarsData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.hero; + if (value != null) { + result + ..add('hero') + ..add(serializers.serialize(value, + specifiedType: const FullType(GHeroNoVarsData_hero))); + } + return result; + } + + @override + GHeroNoVarsData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroNoVarsDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'hero': + result.hero.replace(serializers.deserialize(value, + specifiedType: const FullType(GHeroNoVarsData_hero))! + as GHeroNoVarsData_hero); + break; + } + } + + return result.build(); + } +} + +class _$GHeroNoVarsData_heroSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHeroNoVarsData_hero, + _$GHeroNoVarsData_hero + ]; + @override + final String wireName = 'GHeroNoVarsData_hero'; + + @override + Iterable serialize( + Serializers serializers, GHeroNoVarsData_hero object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'id', + serializers.serialize(object.id, specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GHeroNoVarsData_hero deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroNoVarsData_heroBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'id': + result.id = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + } + } + + return result.build(); + } +} + +class _$GHeroNoVarsData extends GHeroNoVarsData { + @override + final String G__typename; + @override + final GHeroNoVarsData_hero? hero; + + factory _$GHeroNoVarsData([void Function(GHeroNoVarsDataBuilder)? updates]) => + (new GHeroNoVarsDataBuilder()..update(updates))._build(); + + _$GHeroNoVarsData._({required this.G__typename, this.hero}) : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroNoVarsData', 'G__typename'); + } + + @override + GHeroNoVarsData rebuild(void Function(GHeroNoVarsDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroNoVarsDataBuilder toBuilder() => + new GHeroNoVarsDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroNoVarsData && + G__typename == other.G__typename && + hero == other.hero; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, hero.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroNoVarsData') + ..add('G__typename', G__typename) + ..add('hero', hero)) + .toString(); + } +} + +class GHeroNoVarsDataBuilder + implements Builder { + _$GHeroNoVarsData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GHeroNoVarsData_heroBuilder? _hero; + GHeroNoVarsData_heroBuilder get hero => + _$this._hero ??= new GHeroNoVarsData_heroBuilder(); + set hero(GHeroNoVarsData_heroBuilder? hero) => _$this._hero = hero; + + GHeroNoVarsDataBuilder() { + GHeroNoVarsData._initializeBuilder(this); + } + + GHeroNoVarsDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _hero = $v.hero?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GHeroNoVarsData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroNoVarsData; + } + + @override + void update(void Function(GHeroNoVarsDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroNoVarsData build() => _build(); + + _$GHeroNoVarsData _build() { + _$GHeroNoVarsData _$result; + try { + _$result = _$v ?? + new _$GHeroNoVarsData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroNoVarsData', 'G__typename'), + hero: _hero?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'hero'; + _hero?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroNoVarsData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GHeroNoVarsData_hero extends GHeroNoVarsData_hero { + @override + final String G__typename; + @override + final String id; + @override + final String name; + + factory _$GHeroNoVarsData_hero( + [void Function(GHeroNoVarsData_heroBuilder)? updates]) => + (new GHeroNoVarsData_heroBuilder()..update(updates))._build(); + + _$GHeroNoVarsData_hero._( + {required this.G__typename, required this.id, required this.name}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroNoVarsData_hero', 'G__typename'); + BuiltValueNullFieldError.checkNotNull(id, r'GHeroNoVarsData_hero', 'id'); + BuiltValueNullFieldError.checkNotNull( + name, r'GHeroNoVarsData_hero', 'name'); + } + + @override + GHeroNoVarsData_hero rebuild( + void Function(GHeroNoVarsData_heroBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroNoVarsData_heroBuilder toBuilder() => + new GHeroNoVarsData_heroBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroNoVarsData_hero && + G__typename == other.G__typename && + id == other.id && + name == other.name; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroNoVarsData_hero') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('name', name)) + .toString(); + } +} + +class GHeroNoVarsData_heroBuilder + implements Builder { + _$GHeroNoVarsData_hero? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + GHeroNoVarsData_heroBuilder() { + GHeroNoVarsData_hero._initializeBuilder(this); + } + + GHeroNoVarsData_heroBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _name = $v.name; + _$v = null; + } + return this; + } + + @override + void replace(GHeroNoVarsData_hero other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroNoVarsData_hero; + } + + @override + void update(void Function(GHeroNoVarsData_heroBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroNoVarsData_hero build() => _build(); + + _$GHeroNoVarsData_hero _build() { + final _$result = _$v ?? + new _$GHeroNoVarsData_hero._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHeroNoVarsData_hero', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GHeroNoVarsData_hero', 'id'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GHeroNoVarsData_hero', 'name')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.req.gql.dart b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.req.gql.dart new file mode 100644 index 00000000..b30afa94 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.req.gql.dart @@ -0,0 +1,42 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:end_to_end_test_tristate/no_vars/__generated__/hero_no_vars.ast.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/no_vars/__generated__/hero_no_vars.var.gql.dart' + as _i3; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'hero_no_vars.req.gql.g.dart'; + +abstract class GHeroNoVars implements Built { + GHeroNoVars._(); + + factory GHeroNoVars([Function(GHeroNoVarsBuilder b) updates]) = _$GHeroNoVars; + + static void _initializeBuilder(GHeroNoVarsBuilder b) => b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'HeroNoVars', + ); + + _i3.GHeroNoVarsVars get vars; + _i1.Operation get operation; + static Serializer get serializer => _$gHeroNoVarsSerializer; + + Map toJson() => (_i4.serializers.serializeWith( + GHeroNoVars.serializer, + this, + ) as Map); + + static GHeroNoVars? fromJson(Map json) => + _i4.serializers.deserializeWith( + GHeroNoVars.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.req.gql.g.dart b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.req.gql.g.dart new file mode 100644 index 00000000..d42882c5 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.req.gql.g.dart @@ -0,0 +1,171 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'hero_no_vars.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gHeroNoVarsSerializer = new _$GHeroNoVarsSerializer(); + +class _$GHeroNoVarsSerializer implements StructuredSerializer { + @override + final Iterable types = const [GHeroNoVars, _$GHeroNoVars]; + @override + final String wireName = 'GHeroNoVars'; + + @override + Iterable serialize(Serializers serializers, GHeroNoVars object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: const FullType(_i3.GHeroNoVarsVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GHeroNoVars deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHeroNoVarsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'vars': + result.vars.replace(serializers.deserialize(value, + specifiedType: const FullType(_i3.GHeroNoVarsVars))! + as _i3.GHeroNoVarsVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GHeroNoVars extends GHeroNoVars { + @override + final _i3.GHeroNoVarsVars vars; + @override + final _i1.Operation operation; + + factory _$GHeroNoVars([void Function(GHeroNoVarsBuilder)? updates]) => + (new GHeroNoVarsBuilder()..update(updates))._build(); + + _$GHeroNoVars._({required this.vars, required this.operation}) : super._() { + BuiltValueNullFieldError.checkNotNull(vars, r'GHeroNoVars', 'vars'); + BuiltValueNullFieldError.checkNotNull( + operation, r'GHeroNoVars', 'operation'); + } + + @override + GHeroNoVars rebuild(void Function(GHeroNoVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroNoVarsBuilder toBuilder() => new GHeroNoVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroNoVars && + vars == other.vars && + operation == other.operation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHeroNoVars') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GHeroNoVarsBuilder implements Builder { + _$GHeroNoVars? _$v; + + _i3.GHeroNoVarsVarsBuilder? _vars; + _i3.GHeroNoVarsVarsBuilder get vars => + _$this._vars ??= new _i3.GHeroNoVarsVarsBuilder(); + set vars(_i3.GHeroNoVarsVarsBuilder? vars) => _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GHeroNoVarsBuilder() { + GHeroNoVars._initializeBuilder(this); + } + + GHeroNoVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GHeroNoVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroNoVars; + } + + @override + void update(void Function(GHeroNoVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroNoVars build() => _build(); + + _$GHeroNoVars _build() { + _$GHeroNoVars _$result; + try { + _$result = _$v ?? + new _$GHeroNoVars._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull( + operation, r'GHeroNoVars', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHeroNoVars', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.var.gql.dart b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.var.gql.dart new file mode 100644 index 00000000..413f8e4e --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.var.gql.dart @@ -0,0 +1,55 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'hero_no_vars.var.gql.g.dart'; + +abstract class GHeroNoVarsVars + implements Built { + GHeroNoVarsVars._(); + + factory GHeroNoVarsVars([Function(GHeroNoVarsVarsBuilder b) updates]) = + _$GHeroNoVarsVars; + + Map toJson() => (_i1.serializers.serializeWith( + GHeroNoVarsVars.serializer, + this, + ) as Map); + + static GHeroNoVarsVars? fromJson(Map json) => + _i1.serializers.deserializeWith( + GHeroNoVarsVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GHeroNoVarsVarsSerializer(); +} + +class GHeroNoVarsVarsSerializer extends StructuredSerializer { + final String wireName = 'GHeroNoVarsVars'; + + final Iterable types = const [GHeroNoVarsVars, _$GHeroNoVarsVars]; + + Iterable serialize( + Serializers serializers, + GHeroNoVarsVars object, { + FullType specifiedType = FullType.unspecified, + }) { + return const []; + } + + GHeroNoVarsVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + return GHeroNoVarsVars(); + } +} diff --git a/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.var.gql.g.dart b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.var.gql.g.dart new file mode 100644 index 00000000..f5ef2947 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.var.gql.g.dart @@ -0,0 +1,67 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'hero_no_vars.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$GHeroNoVarsVars extends GHeroNoVarsVars { + factory _$GHeroNoVarsVars([void Function(GHeroNoVarsVarsBuilder)? updates]) => + (new GHeroNoVarsVarsBuilder()..update(updates))._build(); + + _$GHeroNoVarsVars._() : super._(); + + @override + GHeroNoVarsVars rebuild(void Function(GHeroNoVarsVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHeroNoVarsVarsBuilder toBuilder() => + new GHeroNoVarsVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHeroNoVarsVars; + } + + @override + int get hashCode { + return 644910002; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GHeroNoVarsVars').toString(); + } +} + +class GHeroNoVarsVarsBuilder + implements Builder { + _$GHeroNoVarsVars? _$v; + + GHeroNoVarsVarsBuilder(); + + @override + void replace(GHeroNoVarsVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHeroNoVarsVars; + } + + @override + void update(void Function(GHeroNoVarsVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHeroNoVarsVars build() => _build(); + + _$GHeroNoVarsVars _build() { + final _$result = _$v ?? new _$GHeroNoVarsVars._(); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/no_vars/hero_no_vars.graphql b/codegen/end_to_end_test_tristate/lib/no_vars/hero_no_vars.graphql new file mode 100644 index 00000000..f4026f9b --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/no_vars/hero_no_vars.graphql @@ -0,0 +1,6 @@ +query HeroNoVars { + hero { + id + name + } +} diff --git a/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.ast.gql.dart b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.ast.gql.dart new file mode 100644 index 00000000..d3b70e19 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.ast.gql.dart @@ -0,0 +1,106 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const ReviewWithDate = _i1.OperationDefinitionNode( + type: _i1.OperationType.mutation, + name: _i1.NameNode(value: 'ReviewWithDate'), + variableDefinitions: [ + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'episode')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Episode'), + isNonNull: false, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ), + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'review')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ReviewInput'), + isNonNull: true, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ), + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'createdAt')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Date'), + isNonNull: false, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ), + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'createReview'), + alias: null, + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'episode'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'episode')), + ), + _i1.ArgumentNode( + name: _i1.NameNode(value: 'review'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'review')), + ), + _i1.ArgumentNode( + name: _i1.NameNode(value: 'createdAt'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'createdAt')), + ), + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'episode'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'stars'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'commentary'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'createdAt'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'seenOn'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'custom'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ) + ]), +); +const document = _i1.DocumentNode(definitions: [ReviewWithDate]); diff --git a/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.data.gql.dart b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.data.gql.dart new file mode 100644 index 00000000..67eb3098 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.data.gql.dart @@ -0,0 +1,79 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_collection/built_collection.dart'; +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/custom_field.dart' as _i3; +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'review_with_date.data.gql.g.dart'; + +abstract class GReviewWithDateData + implements Built { + GReviewWithDateData._(); + + factory GReviewWithDateData( + [Function(GReviewWithDateDataBuilder b) updates]) = _$GReviewWithDateData; + + static void _initializeBuilder(GReviewWithDateDataBuilder b) => + b..G__typename = 'Mutation'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + GReviewWithDateData_createReview? get createReview; + static Serializer get serializer => + _$gReviewWithDateDataSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GReviewWithDateData.serializer, + this, + ) as Map); + + static GReviewWithDateData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GReviewWithDateData.serializer, + json, + ); +} + +abstract class GReviewWithDateData_createReview + implements + Built { + GReviewWithDateData_createReview._(); + + factory GReviewWithDateData_createReview( + [Function(GReviewWithDateData_createReviewBuilder b) updates]) = + _$GReviewWithDateData_createReview; + + static void _initializeBuilder(GReviewWithDateData_createReviewBuilder b) => + b..G__typename = 'Review'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + _i2.GEpisode? get episode; + int get stars; + String? get commentary; + DateTime? get createdAt; + BuiltList get seenOn; + BuiltList<_i3.CustomField> get custom; + static Serializer get serializer => + _$gReviewWithDateDataCreateReviewSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GReviewWithDateData_createReview.serializer, + this, + ) as Map); + + static GReviewWithDateData_createReview? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GReviewWithDateData_createReview.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.data.gql.g.dart b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.data.gql.g.dart new file mode 100644 index 00000000..dd131b05 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.data.gql.g.dart @@ -0,0 +1,487 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'review_with_date.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gReviewWithDateDataSerializer = + new _$GReviewWithDateDataSerializer(); +Serializer + _$gReviewWithDateDataCreateReviewSerializer = + new _$GReviewWithDateData_createReviewSerializer(); + +class _$GReviewWithDateDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GReviewWithDateData, + _$GReviewWithDateData + ]; + @override + final String wireName = 'GReviewWithDateData'; + + @override + Iterable serialize( + Serializers serializers, GReviewWithDateData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.createReview; + if (value != null) { + result + ..add('createReview') + ..add(serializers.serialize(value, + specifiedType: const FullType(GReviewWithDateData_createReview))); + } + return result; + } + + @override + GReviewWithDateData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GReviewWithDateDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'createReview': + result.createReview.replace(serializers.deserialize(value, + specifiedType: + const FullType(GReviewWithDateData_createReview))! + as GReviewWithDateData_createReview); + break; + } + } + + return result.build(); + } +} + +class _$GReviewWithDateData_createReviewSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GReviewWithDateData_createReview, + _$GReviewWithDateData_createReview + ]; + @override + final String wireName = 'GReviewWithDateData_createReview'; + + @override + Iterable serialize( + Serializers serializers, GReviewWithDateData_createReview object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'stars', + serializers.serialize(object.stars, specifiedType: const FullType(int)), + 'seenOn', + serializers.serialize(object.seenOn, + specifiedType: + const FullType(BuiltList, const [const FullType(DateTime)])), + 'custom', + serializers.serialize(object.custom, + specifiedType: const FullType( + BuiltList, const [const FullType(_i3.CustomField)])), + ]; + Object? value; + value = object.episode; + if (value != null) { + result + ..add('episode') + ..add(serializers.serialize(value, + specifiedType: const FullType(_i2.GEpisode))); + } + value = object.commentary; + if (value != null) { + result + ..add('commentary') + ..add(serializers.serialize(value, + specifiedType: const FullType(String))); + } + value = object.createdAt; + if (value != null) { + result + ..add('createdAt') + ..add(serializers.serialize(value, + specifiedType: const FullType(DateTime))); + } + return result; + } + + @override + GReviewWithDateData_createReview deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GReviewWithDateData_createReviewBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'episode': + result.episode = serializers.deserialize(value, + specifiedType: const FullType(_i2.GEpisode)) as _i2.GEpisode?; + break; + case 'stars': + result.stars = serializers.deserialize(value, + specifiedType: const FullType(int))! as int; + break; + case 'commentary': + result.commentary = serializers.deserialize(value, + specifiedType: const FullType(String)) as String?; + break; + case 'createdAt': + result.createdAt = serializers.deserialize(value, + specifiedType: const FullType(DateTime)) as DateTime?; + break; + case 'seenOn': + result.seenOn.replace(serializers.deserialize(value, + specifiedType: const FullType( + BuiltList, const [const FullType(DateTime)]))! + as BuiltList); + break; + case 'custom': + result.custom.replace(serializers.deserialize(value, + specifiedType: const FullType( + BuiltList, const [const FullType(_i3.CustomField)]))! + as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$GReviewWithDateData extends GReviewWithDateData { + @override + final String G__typename; + @override + final GReviewWithDateData_createReview? createReview; + + factory _$GReviewWithDateData( + [void Function(GReviewWithDateDataBuilder)? updates]) => + (new GReviewWithDateDataBuilder()..update(updates))._build(); + + _$GReviewWithDateData._({required this.G__typename, this.createReview}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GReviewWithDateData', 'G__typename'); + } + + @override + GReviewWithDateData rebuild( + void Function(GReviewWithDateDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GReviewWithDateDataBuilder toBuilder() => + new GReviewWithDateDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GReviewWithDateData && + G__typename == other.G__typename && + createReview == other.createReview; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, createReview.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GReviewWithDateData') + ..add('G__typename', G__typename) + ..add('createReview', createReview)) + .toString(); + } +} + +class GReviewWithDateDataBuilder + implements Builder { + _$GReviewWithDateData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GReviewWithDateData_createReviewBuilder? _createReview; + GReviewWithDateData_createReviewBuilder get createReview => + _$this._createReview ??= new GReviewWithDateData_createReviewBuilder(); + set createReview(GReviewWithDateData_createReviewBuilder? createReview) => + _$this._createReview = createReview; + + GReviewWithDateDataBuilder() { + GReviewWithDateData._initializeBuilder(this); + } + + GReviewWithDateDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _createReview = $v.createReview?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GReviewWithDateData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GReviewWithDateData; + } + + @override + void update(void Function(GReviewWithDateDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GReviewWithDateData build() => _build(); + + _$GReviewWithDateData _build() { + _$GReviewWithDateData _$result; + try { + _$result = _$v ?? + new _$GReviewWithDateData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GReviewWithDateData', 'G__typename'), + createReview: _createReview?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'createReview'; + _createReview?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GReviewWithDateData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GReviewWithDateData_createReview + extends GReviewWithDateData_createReview { + @override + final String G__typename; + @override + final _i2.GEpisode? episode; + @override + final int stars; + @override + final String? commentary; + @override + final DateTime? createdAt; + @override + final BuiltList seenOn; + @override + final BuiltList<_i3.CustomField> custom; + + factory _$GReviewWithDateData_createReview( + [void Function(GReviewWithDateData_createReviewBuilder)? updates]) => + (new GReviewWithDateData_createReviewBuilder()..update(updates))._build(); + + _$GReviewWithDateData_createReview._( + {required this.G__typename, + this.episode, + required this.stars, + this.commentary, + this.createdAt, + required this.seenOn, + required this.custom}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GReviewWithDateData_createReview', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + stars, r'GReviewWithDateData_createReview', 'stars'); + BuiltValueNullFieldError.checkNotNull( + seenOn, r'GReviewWithDateData_createReview', 'seenOn'); + BuiltValueNullFieldError.checkNotNull( + custom, r'GReviewWithDateData_createReview', 'custom'); + } + + @override + GReviewWithDateData_createReview rebuild( + void Function(GReviewWithDateData_createReviewBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GReviewWithDateData_createReviewBuilder toBuilder() => + new GReviewWithDateData_createReviewBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GReviewWithDateData_createReview && + G__typename == other.G__typename && + episode == other.episode && + stars == other.stars && + commentary == other.commentary && + createdAt == other.createdAt && + seenOn == other.seenOn && + custom == other.custom; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, episode.hashCode); + _$hash = $jc(_$hash, stars.hashCode); + _$hash = $jc(_$hash, commentary.hashCode); + _$hash = $jc(_$hash, createdAt.hashCode); + _$hash = $jc(_$hash, seenOn.hashCode); + _$hash = $jc(_$hash, custom.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GReviewWithDateData_createReview') + ..add('G__typename', G__typename) + ..add('episode', episode) + ..add('stars', stars) + ..add('commentary', commentary) + ..add('createdAt', createdAt) + ..add('seenOn', seenOn) + ..add('custom', custom)) + .toString(); + } +} + +class GReviewWithDateData_createReviewBuilder + implements + Builder { + _$GReviewWithDateData_createReview? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + _i2.GEpisode? _episode; + _i2.GEpisode? get episode => _$this._episode; + set episode(_i2.GEpisode? episode) => _$this._episode = episode; + + int? _stars; + int? get stars => _$this._stars; + set stars(int? stars) => _$this._stars = stars; + + String? _commentary; + String? get commentary => _$this._commentary; + set commentary(String? commentary) => _$this._commentary = commentary; + + DateTime? _createdAt; + DateTime? get createdAt => _$this._createdAt; + set createdAt(DateTime? createdAt) => _$this._createdAt = createdAt; + + ListBuilder? _seenOn; + ListBuilder get seenOn => + _$this._seenOn ??= new ListBuilder(); + set seenOn(ListBuilder? seenOn) => _$this._seenOn = seenOn; + + ListBuilder<_i3.CustomField>? _custom; + ListBuilder<_i3.CustomField> get custom => + _$this._custom ??= new ListBuilder<_i3.CustomField>(); + set custom(ListBuilder<_i3.CustomField>? custom) => _$this._custom = custom; + + GReviewWithDateData_createReviewBuilder() { + GReviewWithDateData_createReview._initializeBuilder(this); + } + + GReviewWithDateData_createReviewBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _episode = $v.episode; + _stars = $v.stars; + _commentary = $v.commentary; + _createdAt = $v.createdAt; + _seenOn = $v.seenOn.toBuilder(); + _custom = $v.custom.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GReviewWithDateData_createReview other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GReviewWithDateData_createReview; + } + + @override + void update(void Function(GReviewWithDateData_createReviewBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GReviewWithDateData_createReview build() => _build(); + + _$GReviewWithDateData_createReview _build() { + _$GReviewWithDateData_createReview _$result; + try { + _$result = _$v ?? + new _$GReviewWithDateData_createReview._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GReviewWithDateData_createReview', 'G__typename'), + episode: episode, + stars: BuiltValueNullFieldError.checkNotNull( + stars, r'GReviewWithDateData_createReview', 'stars'), + commentary: commentary, + createdAt: createdAt, + seenOn: seenOn.build(), + custom: custom.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'seenOn'; + seenOn.build(); + _$failedField = 'custom'; + custom.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GReviewWithDateData_createReview', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.req.gql.dart b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.req.gql.dart new file mode 100644 index 00000000..ddf707dd --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.req.gql.dart @@ -0,0 +1,45 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:end_to_end_test_tristate/scalars/__generated__/review_with_date.ast.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/scalars/__generated__/review_with_date.var.gql.dart' + as _i3; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'review_with_date.req.gql.g.dart'; + +abstract class GReviewWithDate + implements Built { + GReviewWithDate._(); + + factory GReviewWithDate([Function(GReviewWithDateBuilder b) updates]) = + _$GReviewWithDate; + + static void _initializeBuilder(GReviewWithDateBuilder b) => b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'ReviewWithDate', + ); + + _i3.GReviewWithDateVars get vars; + _i1.Operation get operation; + static Serializer get serializer => + _$gReviewWithDateSerializer; + + Map toJson() => (_i4.serializers.serializeWith( + GReviewWithDate.serializer, + this, + ) as Map); + + static GReviewWithDate? fromJson(Map json) => + _i4.serializers.deserializeWith( + GReviewWithDate.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.req.gql.g.dart b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.req.gql.g.dart new file mode 100644 index 00000000..91d79828 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.req.gql.g.dart @@ -0,0 +1,177 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'review_with_date.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gReviewWithDateSerializer = + new _$GReviewWithDateSerializer(); + +class _$GReviewWithDateSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GReviewWithDate, _$GReviewWithDate]; + @override + final String wireName = 'GReviewWithDate'; + + @override + Iterable serialize(Serializers serializers, GReviewWithDate object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: const FullType(_i3.GReviewWithDateVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GReviewWithDate deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GReviewWithDateBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'vars': + result.vars.replace(serializers.deserialize(value, + specifiedType: const FullType(_i3.GReviewWithDateVars))! + as _i3.GReviewWithDateVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GReviewWithDate extends GReviewWithDate { + @override + final _i3.GReviewWithDateVars vars; + @override + final _i1.Operation operation; + + factory _$GReviewWithDate([void Function(GReviewWithDateBuilder)? updates]) => + (new GReviewWithDateBuilder()..update(updates))._build(); + + _$GReviewWithDate._({required this.vars, required this.operation}) + : super._() { + BuiltValueNullFieldError.checkNotNull(vars, r'GReviewWithDate', 'vars'); + BuiltValueNullFieldError.checkNotNull( + operation, r'GReviewWithDate', 'operation'); + } + + @override + GReviewWithDate rebuild(void Function(GReviewWithDateBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GReviewWithDateBuilder toBuilder() => + new GReviewWithDateBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GReviewWithDate && + vars == other.vars && + operation == other.operation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GReviewWithDate') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GReviewWithDateBuilder + implements Builder { + _$GReviewWithDate? _$v; + + _i3.GReviewWithDateVarsBuilder? _vars; + _i3.GReviewWithDateVarsBuilder get vars => + _$this._vars ??= new _i3.GReviewWithDateVarsBuilder(); + set vars(_i3.GReviewWithDateVarsBuilder? vars) => _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GReviewWithDateBuilder() { + GReviewWithDate._initializeBuilder(this); + } + + GReviewWithDateBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GReviewWithDate other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GReviewWithDate; + } + + @override + void update(void Function(GReviewWithDateBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GReviewWithDate build() => _build(); + + _$GReviewWithDate _build() { + _$GReviewWithDate _$result; + try { + _$result = _$v ?? + new _$GReviewWithDate._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull( + operation, r'GReviewWithDate', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GReviewWithDate', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.dart b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.dart new file mode 100644 index 00000000..bcecfafc --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.dart @@ -0,0 +1,110 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i3; +import 'package:gql_exec/value.dart' as _i1; + +part 'review_with_date.var.gql.g.dart'; + +abstract class GReviewWithDateVars + implements Built { + GReviewWithDateVars._(); + + factory GReviewWithDateVars( + [Function(GReviewWithDateVarsBuilder b) updates]) = _$GReviewWithDateVars; + + static void _initializeBuilder(GReviewWithDateVarsBuilder b) => b + ..episode = const _i1.AbsentValue() + ..createdAt = const _i1.AbsentValue(); + + _i1.Value<_i2.GEpisode>? get episode; + _i2.GReviewInput get review; + _i1.Value? get createdAt; + Map toJson() => (_i3.serializers.serializeWith( + GReviewWithDateVars.serializer, + this, + ) as Map); + + static GReviewWithDateVars? fromJson(Map json) => + _i3.serializers.deserializeWith( + GReviewWithDateVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GReviewWithDateVarsSerializer(); +} + +class GReviewWithDateVarsSerializer + extends StructuredSerializer { + final String wireName = 'GReviewWithDateVars'; + + final Iterable types = const [ + GReviewWithDateVars, + _$GReviewWithDateVars + ]; + + Iterable serialize( + Serializers serializers, + GReviewWithDateVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + final _$episodevalue = object.episode; + if (_$episodevalue case _i1.PresentValue(value: final _$value)) { + result.add('episode'); + result.add(serializers.serialize(_$value, + specifiedType: const FullType(_i2.GEpisode))); + } + result.add('review'); + result.add(serializers.serialize(object.review, + specifiedType: const FullType(_i2.GReviewInput))); + final _$createdAtvalue = object.createdAt; + if (_$createdAtvalue case _i1.PresentValue(value: final _$value)) { + result.add('createdAt'); + result.add(serializers.serialize(_$value, + specifiedType: const FullType(DateTime))); + } + return result; + } + + GReviewWithDateVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GReviewWithDateVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'episode': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i2.GEpisode)) as _i2.GEpisode; + builder.episode = _i1.PresentValue(fieldValue); + break; + case 'review': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i2.GReviewInput)) + as _i2.GReviewInput; + builder.review.replace(fieldValue); + break; + case 'createdAt': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(DateTime)) as DateTime; + builder.createdAt = _i1.PresentValue(fieldValue); + break; + } + } + return builder.build(); + } +} diff --git a/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.g.dart b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.g.dart new file mode 100644 index 00000000..0bedf48c --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.g.dart @@ -0,0 +1,134 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'review_with_date.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$GReviewWithDateVars extends GReviewWithDateVars { + @override + final _i1.Value<_i2.GEpisode>? episode; + @override + final _i2.GReviewInput review; + @override + final _i1.Value? createdAt; + + factory _$GReviewWithDateVars( + [void Function(GReviewWithDateVarsBuilder)? updates]) => + (new GReviewWithDateVarsBuilder()..update(updates))._build(); + + _$GReviewWithDateVars._({this.episode, required this.review, this.createdAt}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + review, r'GReviewWithDateVars', 'review'); + } + + @override + GReviewWithDateVars rebuild( + void Function(GReviewWithDateVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GReviewWithDateVarsBuilder toBuilder() => + new GReviewWithDateVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GReviewWithDateVars && + episode == other.episode && + review == other.review && + createdAt == other.createdAt; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, episode.hashCode); + _$hash = $jc(_$hash, review.hashCode); + _$hash = $jc(_$hash, createdAt.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GReviewWithDateVars') + ..add('episode', episode) + ..add('review', review) + ..add('createdAt', createdAt)) + .toString(); + } +} + +class GReviewWithDateVarsBuilder + implements Builder { + _$GReviewWithDateVars? _$v; + + _i1.Value<_i2.GEpisode>? _episode; + _i1.Value<_i2.GEpisode>? get episode => _$this._episode; + set episode(_i1.Value<_i2.GEpisode>? episode) => _$this._episode = episode; + + _i2.GReviewInputBuilder? _review; + _i2.GReviewInputBuilder get review => + _$this._review ??= new _i2.GReviewInputBuilder(); + set review(_i2.GReviewInputBuilder? review) => _$this._review = review; + + _i1.Value? _createdAt; + _i1.Value? get createdAt => _$this._createdAt; + set createdAt(_i1.Value? createdAt) => + _$this._createdAt = createdAt; + + GReviewWithDateVarsBuilder() { + GReviewWithDateVars._initializeBuilder(this); + } + + GReviewWithDateVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _episode = $v.episode; + _review = $v.review.toBuilder(); + _createdAt = $v.createdAt; + _$v = null; + } + return this; + } + + @override + void replace(GReviewWithDateVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GReviewWithDateVars; + } + + @override + void update(void Function(GReviewWithDateVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GReviewWithDateVars build() => _build(); + + _$GReviewWithDateVars _build() { + _$GReviewWithDateVars _$result; + try { + _$result = _$v ?? + new _$GReviewWithDateVars._( + episode: episode, review: review.build(), createdAt: createdAt); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'review'; + review.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GReviewWithDateVars', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/scalars/review_with_date.graphql b/codegen/end_to_end_test_tristate/lib/scalars/review_with_date.graphql new file mode 100644 index 00000000..5cad0ddd --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/scalars/review_with_date.graphql @@ -0,0 +1,14 @@ +mutation ReviewWithDate( + $episode: Episode + $review: ReviewInput! + $createdAt: Date +) { + createReview(episode: $episode, review: $review, createdAt: $createdAt) { + episode + stars + commentary + createdAt + seenOn + custom + } +} diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.ast.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.ast.gql.dart new file mode 100644 index 00000000..31da7675 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.ast.gql.dart @@ -0,0 +1,37 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const CreateCustomField = _i1.OperationDefinitionNode( + type: _i1.OperationType.mutation, + name: _i1.NameNode(value: 'CreateCustomField'), + variableDefinitions: [ + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'input')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'CustomFieldInput'), + isNonNull: true, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'createCustomField'), + alias: null, + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'input'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'input')), + ) + ], + directives: [], + selectionSet: null, + ) + ]), +); +const document = _i1.DocumentNode(definitions: [CreateCustomField]); diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.data.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.data.gql.dart new file mode 100644 index 00000000..dd4675a7 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.data.gql.dart @@ -0,0 +1,40 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/custom_field.dart' as _i1; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i2; + +part 'create_custom_field.data.gql.g.dart'; + +abstract class GCreateCustomFieldData + implements Built { + GCreateCustomFieldData._(); + + factory GCreateCustomFieldData( + [Function(GCreateCustomFieldDataBuilder b) updates]) = + _$GCreateCustomFieldData; + + static void _initializeBuilder(GCreateCustomFieldDataBuilder b) => + b..G__typename = 'Mutation'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + _i1.CustomField? get createCustomField; + static Serializer get serializer => + _$gCreateCustomFieldDataSerializer; + + Map toJson() => (_i2.serializers.serializeWith( + GCreateCustomFieldData.serializer, + this, + ) as Map); + + static GCreateCustomFieldData? fromJson(Map json) => + _i2.serializers.deserializeWith( + GCreateCustomFieldData.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.data.gql.g.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.data.gql.g.dart new file mode 100644 index 00000000..2b151a87 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.data.gql.g.dart @@ -0,0 +1,174 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'create_custom_field.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gCreateCustomFieldDataSerializer = + new _$GCreateCustomFieldDataSerializer(); + +class _$GCreateCustomFieldDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GCreateCustomFieldData, + _$GCreateCustomFieldData + ]; + @override + final String wireName = 'GCreateCustomFieldData'; + + @override + Iterable serialize( + Serializers serializers, GCreateCustomFieldData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.createCustomField; + if (value != null) { + result + ..add('createCustomField') + ..add(serializers.serialize(value, + specifiedType: const FullType(_i1.CustomField))); + } + return result; + } + + @override + GCreateCustomFieldData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GCreateCustomFieldDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'createCustomField': + result.createCustomField = serializers.deserialize(value, + specifiedType: const FullType(_i1.CustomField)) + as _i1.CustomField?; + break; + } + } + + return result.build(); + } +} + +class _$GCreateCustomFieldData extends GCreateCustomFieldData { + @override + final String G__typename; + @override + final _i1.CustomField? createCustomField; + + factory _$GCreateCustomFieldData( + [void Function(GCreateCustomFieldDataBuilder)? updates]) => + (new GCreateCustomFieldDataBuilder()..update(updates))._build(); + + _$GCreateCustomFieldData._( + {required this.G__typename, this.createCustomField}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GCreateCustomFieldData', 'G__typename'); + } + + @override + GCreateCustomFieldData rebuild( + void Function(GCreateCustomFieldDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GCreateCustomFieldDataBuilder toBuilder() => + new GCreateCustomFieldDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GCreateCustomFieldData && + G__typename == other.G__typename && + createCustomField == other.createCustomField; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, createCustomField.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GCreateCustomFieldData') + ..add('G__typename', G__typename) + ..add('createCustomField', createCustomField)) + .toString(); + } +} + +class GCreateCustomFieldDataBuilder + implements Builder { + _$GCreateCustomFieldData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + _i1.CustomField? _createCustomField; + _i1.CustomField? get createCustomField => _$this._createCustomField; + set createCustomField(_i1.CustomField? createCustomField) => + _$this._createCustomField = createCustomField; + + GCreateCustomFieldDataBuilder() { + GCreateCustomFieldData._initializeBuilder(this); + } + + GCreateCustomFieldDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _createCustomField = $v.createCustomField; + _$v = null; + } + return this; + } + + @override + void replace(GCreateCustomFieldData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GCreateCustomFieldData; + } + + @override + void update(void Function(GCreateCustomFieldDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GCreateCustomFieldData build() => _build(); + + _$GCreateCustomFieldData _build() { + final _$result = _$v ?? + new _$GCreateCustomFieldData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GCreateCustomFieldData', 'G__typename'), + createCustomField: createCustomField); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.req.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.req.gql.dart new file mode 100644 index 00000000..a4446b6a --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.req.gql.dart @@ -0,0 +1,45 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:end_to_end_test_tristate/variables/__generated__/create_custom_field.ast.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/variables/__generated__/create_custom_field.var.gql.dart' + as _i3; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'create_custom_field.req.gql.g.dart'; + +abstract class GCreateCustomField + implements Built { + GCreateCustomField._(); + + factory GCreateCustomField([Function(GCreateCustomFieldBuilder b) updates]) = + _$GCreateCustomField; + + static void _initializeBuilder(GCreateCustomFieldBuilder b) => b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'CreateCustomField', + ); + + _i3.GCreateCustomFieldVars get vars; + _i1.Operation get operation; + static Serializer get serializer => + _$gCreateCustomFieldSerializer; + + Map toJson() => (_i4.serializers.serializeWith( + GCreateCustomField.serializer, + this, + ) as Map); + + static GCreateCustomField? fromJson(Map json) => + _i4.serializers.deserializeWith( + GCreateCustomField.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.req.gql.g.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.req.gql.g.dart new file mode 100644 index 00000000..0ab4ab8f --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.req.gql.g.dart @@ -0,0 +1,180 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'create_custom_field.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gCreateCustomFieldSerializer = + new _$GCreateCustomFieldSerializer(); + +class _$GCreateCustomFieldSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GCreateCustomField, _$GCreateCustomField]; + @override + final String wireName = 'GCreateCustomField'; + + @override + Iterable serialize( + Serializers serializers, GCreateCustomField object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: const FullType(_i3.GCreateCustomFieldVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GCreateCustomField deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GCreateCustomFieldBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'vars': + result.vars.replace(serializers.deserialize(value, + specifiedType: const FullType(_i3.GCreateCustomFieldVars))! + as _i3.GCreateCustomFieldVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GCreateCustomField extends GCreateCustomField { + @override + final _i3.GCreateCustomFieldVars vars; + @override + final _i1.Operation operation; + + factory _$GCreateCustomField( + [void Function(GCreateCustomFieldBuilder)? updates]) => + (new GCreateCustomFieldBuilder()..update(updates))._build(); + + _$GCreateCustomField._({required this.vars, required this.operation}) + : super._() { + BuiltValueNullFieldError.checkNotNull(vars, r'GCreateCustomField', 'vars'); + BuiltValueNullFieldError.checkNotNull( + operation, r'GCreateCustomField', 'operation'); + } + + @override + GCreateCustomField rebuild( + void Function(GCreateCustomFieldBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GCreateCustomFieldBuilder toBuilder() => + new GCreateCustomFieldBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GCreateCustomField && + vars == other.vars && + operation == other.operation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GCreateCustomField') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GCreateCustomFieldBuilder + implements Builder { + _$GCreateCustomField? _$v; + + _i3.GCreateCustomFieldVarsBuilder? _vars; + _i3.GCreateCustomFieldVarsBuilder get vars => + _$this._vars ??= new _i3.GCreateCustomFieldVarsBuilder(); + set vars(_i3.GCreateCustomFieldVarsBuilder? vars) => _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GCreateCustomFieldBuilder() { + GCreateCustomField._initializeBuilder(this); + } + + GCreateCustomFieldBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GCreateCustomField other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GCreateCustomField; + } + + @override + void update(void Function(GCreateCustomFieldBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GCreateCustomField build() => _build(); + + _$GCreateCustomField _build() { + _$GCreateCustomField _$result; + try { + _$result = _$v ?? + new _$GCreateCustomField._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull( + operation, r'GCreateCustomField', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GCreateCustomField', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.dart new file mode 100644 index 00000000..44f2c7fc --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.dart @@ -0,0 +1,82 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart' + as _i1; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i2; + +part 'create_custom_field.var.gql.g.dart'; + +abstract class GCreateCustomFieldVars + implements Built { + GCreateCustomFieldVars._(); + + factory GCreateCustomFieldVars( + [Function(GCreateCustomFieldVarsBuilder b) updates]) = + _$GCreateCustomFieldVars; + + _i1.GCustomFieldInput get input; + Map toJson() => (_i2.serializers.serializeWith( + GCreateCustomFieldVars.serializer, + this, + ) as Map); + + static GCreateCustomFieldVars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GCreateCustomFieldVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GCreateCustomFieldVarsSerializer(); +} + +class GCreateCustomFieldVarsSerializer + extends StructuredSerializer { + final String wireName = 'GCreateCustomFieldVars'; + + final Iterable types = const [ + GCreateCustomFieldVars, + _$GCreateCustomFieldVars + ]; + + Iterable serialize( + Serializers serializers, + GCreateCustomFieldVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('input'); + result.add(serializers.serialize(object.input, + specifiedType: const FullType(_i1.GCustomFieldInput))); + return result; + } + + GCreateCustomFieldVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GCreateCustomFieldVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'input': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i1.GCustomFieldInput)) + as _i1.GCustomFieldInput; + builder.input.replace(fieldValue); + break; + } + } + return builder.build(); + } +} diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.g.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.g.dart new file mode 100644 index 00000000..a4582afc --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.g.dart @@ -0,0 +1,107 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'create_custom_field.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$GCreateCustomFieldVars extends GCreateCustomFieldVars { + @override + final _i1.GCustomFieldInput input; + + factory _$GCreateCustomFieldVars( + [void Function(GCreateCustomFieldVarsBuilder)? updates]) => + (new GCreateCustomFieldVarsBuilder()..update(updates))._build(); + + _$GCreateCustomFieldVars._({required this.input}) : super._() { + BuiltValueNullFieldError.checkNotNull( + input, r'GCreateCustomFieldVars', 'input'); + } + + @override + GCreateCustomFieldVars rebuild( + void Function(GCreateCustomFieldVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GCreateCustomFieldVarsBuilder toBuilder() => + new GCreateCustomFieldVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GCreateCustomFieldVars && input == other.input; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, input.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GCreateCustomFieldVars') + ..add('input', input)) + .toString(); + } +} + +class GCreateCustomFieldVarsBuilder + implements Builder { + _$GCreateCustomFieldVars? _$v; + + _i1.GCustomFieldInputBuilder? _input; + _i1.GCustomFieldInputBuilder get input => + _$this._input ??= new _i1.GCustomFieldInputBuilder(); + set input(_i1.GCustomFieldInputBuilder? input) => _$this._input = input; + + GCreateCustomFieldVarsBuilder(); + + GCreateCustomFieldVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _input = $v.input.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GCreateCustomFieldVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GCreateCustomFieldVars; + } + + @override + void update(void Function(GCreateCustomFieldVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GCreateCustomFieldVars build() => _build(); + + _$GCreateCustomFieldVars _build() { + _$GCreateCustomFieldVars _$result; + try { + _$result = _$v ?? new _$GCreateCustomFieldVars._(input: input.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'input'; + input.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GCreateCustomFieldVars', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.ast.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.ast.gql.dart new file mode 100644 index 00000000..8c04ed24 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.ast.gql.dart @@ -0,0 +1,72 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const CreateReview = _i1.OperationDefinitionNode( + type: _i1.OperationType.mutation, + name: _i1.NameNode(value: 'CreateReview'), + variableDefinitions: [ + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'episode')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Episode'), + isNonNull: false, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ), + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'review')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ReviewInput'), + isNonNull: true, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ), + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'createReview'), + alias: null, + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'episode'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'episode')), + ), + _i1.ArgumentNode( + name: _i1.NameNode(value: 'review'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'review')), + ), + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'episode'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'stars'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'commentary'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ) + ]), +); +const document = _i1.DocumentNode(definitions: [CreateReview]); diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.data.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.data.gql.dart new file mode 100644 index 00000000..5cfd60b1 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.data.gql.dart @@ -0,0 +1,73 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'create_review.data.gql.g.dart'; + +abstract class GCreateReviewData + implements Built { + GCreateReviewData._(); + + factory GCreateReviewData([Function(GCreateReviewDataBuilder b) updates]) = + _$GCreateReviewData; + + static void _initializeBuilder(GCreateReviewDataBuilder b) => + b..G__typename = 'Mutation'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + GCreateReviewData_createReview? get createReview; + static Serializer get serializer => + _$gCreateReviewDataSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GCreateReviewData.serializer, + this, + ) as Map); + + static GCreateReviewData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GCreateReviewData.serializer, + json, + ); +} + +abstract class GCreateReviewData_createReview + implements + Built { + GCreateReviewData_createReview._(); + + factory GCreateReviewData_createReview( + [Function(GCreateReviewData_createReviewBuilder b) updates]) = + _$GCreateReviewData_createReview; + + static void _initializeBuilder(GCreateReviewData_createReviewBuilder b) => + b..G__typename = 'Review'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + _i2.GEpisode? get episode; + int get stars; + String? get commentary; + static Serializer get serializer => + _$gCreateReviewDataCreateReviewSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GCreateReviewData_createReview.serializer, + this, + ) as Map); + + static GCreateReviewData_createReview? fromJson(Map json) => + _i1.serializers.deserializeWith( + GCreateReviewData_createReview.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.data.gql.g.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.data.gql.g.dart new file mode 100644 index 00000000..9a91b574 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.data.gql.g.dart @@ -0,0 +1,393 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'create_review.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gCreateReviewDataSerializer = + new _$GCreateReviewDataSerializer(); +Serializer + _$gCreateReviewDataCreateReviewSerializer = + new _$GCreateReviewData_createReviewSerializer(); + +class _$GCreateReviewDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GCreateReviewData, _$GCreateReviewData]; + @override + final String wireName = 'GCreateReviewData'; + + @override + Iterable serialize(Serializers serializers, GCreateReviewData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.createReview; + if (value != null) { + result + ..add('createReview') + ..add(serializers.serialize(value, + specifiedType: const FullType(GCreateReviewData_createReview))); + } + return result; + } + + @override + GCreateReviewData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GCreateReviewDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'createReview': + result.createReview.replace(serializers.deserialize(value, + specifiedType: + const FullType(GCreateReviewData_createReview))! + as GCreateReviewData_createReview); + break; + } + } + + return result.build(); + } +} + +class _$GCreateReviewData_createReviewSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GCreateReviewData_createReview, + _$GCreateReviewData_createReview + ]; + @override + final String wireName = 'GCreateReviewData_createReview'; + + @override + Iterable serialize( + Serializers serializers, GCreateReviewData_createReview object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'stars', + serializers.serialize(object.stars, specifiedType: const FullType(int)), + ]; + Object? value; + value = object.episode; + if (value != null) { + result + ..add('episode') + ..add(serializers.serialize(value, + specifiedType: const FullType(_i2.GEpisode))); + } + value = object.commentary; + if (value != null) { + result + ..add('commentary') + ..add(serializers.serialize(value, + specifiedType: const FullType(String))); + } + return result; + } + + @override + GCreateReviewData_createReview deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GCreateReviewData_createReviewBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'episode': + result.episode = serializers.deserialize(value, + specifiedType: const FullType(_i2.GEpisode)) as _i2.GEpisode?; + break; + case 'stars': + result.stars = serializers.deserialize(value, + specifiedType: const FullType(int))! as int; + break; + case 'commentary': + result.commentary = serializers.deserialize(value, + specifiedType: const FullType(String)) as String?; + break; + } + } + + return result.build(); + } +} + +class _$GCreateReviewData extends GCreateReviewData { + @override + final String G__typename; + @override + final GCreateReviewData_createReview? createReview; + + factory _$GCreateReviewData( + [void Function(GCreateReviewDataBuilder)? updates]) => + (new GCreateReviewDataBuilder()..update(updates))._build(); + + _$GCreateReviewData._({required this.G__typename, this.createReview}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GCreateReviewData', 'G__typename'); + } + + @override + GCreateReviewData rebuild(void Function(GCreateReviewDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GCreateReviewDataBuilder toBuilder() => + new GCreateReviewDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GCreateReviewData && + G__typename == other.G__typename && + createReview == other.createReview; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, createReview.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GCreateReviewData') + ..add('G__typename', G__typename) + ..add('createReview', createReview)) + .toString(); + } +} + +class GCreateReviewDataBuilder + implements Builder { + _$GCreateReviewData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GCreateReviewData_createReviewBuilder? _createReview; + GCreateReviewData_createReviewBuilder get createReview => + _$this._createReview ??= new GCreateReviewData_createReviewBuilder(); + set createReview(GCreateReviewData_createReviewBuilder? createReview) => + _$this._createReview = createReview; + + GCreateReviewDataBuilder() { + GCreateReviewData._initializeBuilder(this); + } + + GCreateReviewDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _createReview = $v.createReview?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GCreateReviewData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GCreateReviewData; + } + + @override + void update(void Function(GCreateReviewDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GCreateReviewData build() => _build(); + + _$GCreateReviewData _build() { + _$GCreateReviewData _$result; + try { + _$result = _$v ?? + new _$GCreateReviewData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GCreateReviewData', 'G__typename'), + createReview: _createReview?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'createReview'; + _createReview?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GCreateReviewData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GCreateReviewData_createReview extends GCreateReviewData_createReview { + @override + final String G__typename; + @override + final _i2.GEpisode? episode; + @override + final int stars; + @override + final String? commentary; + + factory _$GCreateReviewData_createReview( + [void Function(GCreateReviewData_createReviewBuilder)? updates]) => + (new GCreateReviewData_createReviewBuilder()..update(updates))._build(); + + _$GCreateReviewData_createReview._( + {required this.G__typename, + this.episode, + required this.stars, + this.commentary}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GCreateReviewData_createReview', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + stars, r'GCreateReviewData_createReview', 'stars'); + } + + @override + GCreateReviewData_createReview rebuild( + void Function(GCreateReviewData_createReviewBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GCreateReviewData_createReviewBuilder toBuilder() => + new GCreateReviewData_createReviewBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GCreateReviewData_createReview && + G__typename == other.G__typename && + episode == other.episode && + stars == other.stars && + commentary == other.commentary; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, episode.hashCode); + _$hash = $jc(_$hash, stars.hashCode); + _$hash = $jc(_$hash, commentary.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GCreateReviewData_createReview') + ..add('G__typename', G__typename) + ..add('episode', episode) + ..add('stars', stars) + ..add('commentary', commentary)) + .toString(); + } +} + +class GCreateReviewData_createReviewBuilder + implements + Builder { + _$GCreateReviewData_createReview? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + _i2.GEpisode? _episode; + _i2.GEpisode? get episode => _$this._episode; + set episode(_i2.GEpisode? episode) => _$this._episode = episode; + + int? _stars; + int? get stars => _$this._stars; + set stars(int? stars) => _$this._stars = stars; + + String? _commentary; + String? get commentary => _$this._commentary; + set commentary(String? commentary) => _$this._commentary = commentary; + + GCreateReviewData_createReviewBuilder() { + GCreateReviewData_createReview._initializeBuilder(this); + } + + GCreateReviewData_createReviewBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _episode = $v.episode; + _stars = $v.stars; + _commentary = $v.commentary; + _$v = null; + } + return this; + } + + @override + void replace(GCreateReviewData_createReview other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GCreateReviewData_createReview; + } + + @override + void update(void Function(GCreateReviewData_createReviewBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GCreateReviewData_createReview build() => _build(); + + _$GCreateReviewData_createReview _build() { + final _$result = _$v ?? + new _$GCreateReviewData_createReview._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GCreateReviewData_createReview', 'G__typename'), + episode: episode, + stars: BuiltValueNullFieldError.checkNotNull( + stars, r'GCreateReviewData_createReview', 'stars'), + commentary: commentary); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.req.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.req.gql.dart new file mode 100644 index 00000000..3bd20468 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.req.gql.dart @@ -0,0 +1,44 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:end_to_end_test_tristate/variables/__generated__/create_review.ast.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/variables/__generated__/create_review.var.gql.dart' + as _i3; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'create_review.req.gql.g.dart'; + +abstract class GCreateReview + implements Built { + GCreateReview._(); + + factory GCreateReview([Function(GCreateReviewBuilder b) updates]) = + _$GCreateReview; + + static void _initializeBuilder(GCreateReviewBuilder b) => b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'CreateReview', + ); + + _i3.GCreateReviewVars get vars; + _i1.Operation get operation; + static Serializer get serializer => _$gCreateReviewSerializer; + + Map toJson() => (_i4.serializers.serializeWith( + GCreateReview.serializer, + this, + ) as Map); + + static GCreateReview? fromJson(Map json) => + _i4.serializers.deserializeWith( + GCreateReview.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.req.gql.g.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.req.gql.g.dart new file mode 100644 index 00000000..a8262c04 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.req.gql.g.dart @@ -0,0 +1,174 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'create_review.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gCreateReviewSerializer = + new _$GCreateReviewSerializer(); + +class _$GCreateReviewSerializer implements StructuredSerializer { + @override + final Iterable types = const [GCreateReview, _$GCreateReview]; + @override + final String wireName = 'GCreateReview'; + + @override + Iterable serialize(Serializers serializers, GCreateReview object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: const FullType(_i3.GCreateReviewVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GCreateReview deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GCreateReviewBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'vars': + result.vars.replace(serializers.deserialize(value, + specifiedType: const FullType(_i3.GCreateReviewVars))! + as _i3.GCreateReviewVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GCreateReview extends GCreateReview { + @override + final _i3.GCreateReviewVars vars; + @override + final _i1.Operation operation; + + factory _$GCreateReview([void Function(GCreateReviewBuilder)? updates]) => + (new GCreateReviewBuilder()..update(updates))._build(); + + _$GCreateReview._({required this.vars, required this.operation}) : super._() { + BuiltValueNullFieldError.checkNotNull(vars, r'GCreateReview', 'vars'); + BuiltValueNullFieldError.checkNotNull( + operation, r'GCreateReview', 'operation'); + } + + @override + GCreateReview rebuild(void Function(GCreateReviewBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GCreateReviewBuilder toBuilder() => new GCreateReviewBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GCreateReview && + vars == other.vars && + operation == other.operation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GCreateReview') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GCreateReviewBuilder + implements Builder { + _$GCreateReview? _$v; + + _i3.GCreateReviewVarsBuilder? _vars; + _i3.GCreateReviewVarsBuilder get vars => + _$this._vars ??= new _i3.GCreateReviewVarsBuilder(); + set vars(_i3.GCreateReviewVarsBuilder? vars) => _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GCreateReviewBuilder() { + GCreateReview._initializeBuilder(this); + } + + GCreateReviewBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GCreateReview other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GCreateReview; + } + + @override + void update(void Function(GCreateReviewBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GCreateReview build() => _build(); + + _$GCreateReview _build() { + _$GCreateReview _$result; + try { + _$result = _$v ?? + new _$GCreateReview._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull( + operation, r'GCreateReview', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GCreateReview', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.dart new file mode 100644 index 00000000..8899db93 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.dart @@ -0,0 +1,94 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i3; +import 'package:gql_exec/value.dart' as _i1; + +part 'create_review.var.gql.g.dart'; + +abstract class GCreateReviewVars + implements Built { + GCreateReviewVars._(); + + factory GCreateReviewVars([Function(GCreateReviewVarsBuilder b) updates]) = + _$GCreateReviewVars; + + static void _initializeBuilder(GCreateReviewVarsBuilder b) => + b..episode = const _i1.AbsentValue(); + + _i1.Value<_i2.GEpisode>? get episode; + _i2.GReviewInput get review; + Map toJson() => (_i3.serializers.serializeWith( + GCreateReviewVars.serializer, + this, + ) as Map); + + static GCreateReviewVars? fromJson(Map json) => + _i3.serializers.deserializeWith( + GCreateReviewVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GCreateReviewVarsSerializer(); +} + +class GCreateReviewVarsSerializer + extends StructuredSerializer { + final String wireName = 'GCreateReviewVars'; + + final Iterable types = const [GCreateReviewVars, _$GCreateReviewVars]; + + Iterable serialize( + Serializers serializers, + GCreateReviewVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + final _$episodevalue = object.episode; + if (_$episodevalue case _i1.PresentValue(value: final _$value)) { + result.add('episode'); + result.add(serializers.serialize(_$value, + specifiedType: const FullType(_i2.GEpisode))); + } + result.add('review'); + result.add(serializers.serialize(object.review, + specifiedType: const FullType(_i2.GReviewInput))); + return result; + } + + GCreateReviewVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GCreateReviewVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'episode': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i2.GEpisode)) as _i2.GEpisode; + builder.episode = _i1.PresentValue(fieldValue); + break; + case 'review': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(_i2.GReviewInput)) + as _i2.GReviewInput; + builder.review.replace(fieldValue); + break; + } + } + return builder.build(); + } +} diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.g.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.g.dart new file mode 100644 index 00000000..da074bea --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.g.dart @@ -0,0 +1,120 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'create_review.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$GCreateReviewVars extends GCreateReviewVars { + @override + final _i1.Value<_i2.GEpisode>? episode; + @override + final _i2.GReviewInput review; + + factory _$GCreateReviewVars( + [void Function(GCreateReviewVarsBuilder)? updates]) => + (new GCreateReviewVarsBuilder()..update(updates))._build(); + + _$GCreateReviewVars._({this.episode, required this.review}) : super._() { + BuiltValueNullFieldError.checkNotNull( + review, r'GCreateReviewVars', 'review'); + } + + @override + GCreateReviewVars rebuild(void Function(GCreateReviewVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GCreateReviewVarsBuilder toBuilder() => + new GCreateReviewVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GCreateReviewVars && + episode == other.episode && + review == other.review; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, episode.hashCode); + _$hash = $jc(_$hash, review.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GCreateReviewVars') + ..add('episode', episode) + ..add('review', review)) + .toString(); + } +} + +class GCreateReviewVarsBuilder + implements Builder { + _$GCreateReviewVars? _$v; + + _i1.Value<_i2.GEpisode>? _episode; + _i1.Value<_i2.GEpisode>? get episode => _$this._episode; + set episode(_i1.Value<_i2.GEpisode>? episode) => _$this._episode = episode; + + _i2.GReviewInputBuilder? _review; + _i2.GReviewInputBuilder get review => + _$this._review ??= new _i2.GReviewInputBuilder(); + set review(_i2.GReviewInputBuilder? review) => _$this._review = review; + + GCreateReviewVarsBuilder() { + GCreateReviewVars._initializeBuilder(this); + } + + GCreateReviewVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _episode = $v.episode; + _review = $v.review.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GCreateReviewVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GCreateReviewVars; + } + + @override + void update(void Function(GCreateReviewVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GCreateReviewVars build() => _build(); + + _$GCreateReviewVars _build() { + _$GCreateReviewVars _$result; + try { + _$result = _$v ?? + new _$GCreateReviewVars._(episode: episode, review: review.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'review'; + review.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GCreateReviewVars', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.ast.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.ast.gql.dart new file mode 100644 index 00000000..50b7f681 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.ast.gql.dart @@ -0,0 +1,52 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:gql/ast.dart' as _i1; + +const HumanWithArgs = _i1.OperationDefinitionNode( + type: _i1.OperationType.query, + name: _i1.NameNode(value: 'HumanWithArgs'), + variableDefinitions: [ + _i1.VariableDefinitionNode( + variable: _i1.VariableNode(name: _i1.NameNode(value: 'id')), + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + defaultValue: _i1.DefaultValueNode(value: null), + directives: [], + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'human'), + alias: null, + arguments: [ + _i1.ArgumentNode( + name: _i1.NameNode(value: 'id'), + value: _i1.VariableNode(name: _i1.NameNode(value: 'id')), + ) + ], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'height'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ) + ]), +); +const document = _i1.DocumentNode(definitions: [HumanWithArgs]); diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.data.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.data.gql.dart new file mode 100644 index 00000000..361241c4 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.data.gql.dart @@ -0,0 +1,69 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'human_with_args.data.gql.g.dart'; + +abstract class GHumanWithArgsData + implements Built { + GHumanWithArgsData._(); + + factory GHumanWithArgsData([Function(GHumanWithArgsDataBuilder b) updates]) = + _$GHumanWithArgsData; + + static void _initializeBuilder(GHumanWithArgsDataBuilder b) => + b..G__typename = 'Query'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + GHumanWithArgsData_human? get human; + static Serializer get serializer => + _$gHumanWithArgsDataSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GHumanWithArgsData.serializer, + this, + ) as Map); + + static GHumanWithArgsData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GHumanWithArgsData.serializer, + json, + ); +} + +abstract class GHumanWithArgsData_human + implements + Built { + GHumanWithArgsData_human._(); + + factory GHumanWithArgsData_human( + [Function(GHumanWithArgsData_humanBuilder b) updates]) = + _$GHumanWithArgsData_human; + + static void _initializeBuilder(GHumanWithArgsData_humanBuilder b) => + b..G__typename = 'Human'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + String get name; + double? get height; + static Serializer get serializer => + _$gHumanWithArgsDataHumanSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GHumanWithArgsData_human.serializer, + this, + ) as Map); + + static GHumanWithArgsData_human? fromJson(Map json) => + _i1.serializers.deserializeWith( + GHumanWithArgsData_human.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.data.gql.g.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.data.gql.g.dart new file mode 100644 index 00000000..4557ba55 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.data.gql.g.dart @@ -0,0 +1,365 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'human_with_args.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gHumanWithArgsDataSerializer = + new _$GHumanWithArgsDataSerializer(); +Serializer _$gHumanWithArgsDataHumanSerializer = + new _$GHumanWithArgsData_humanSerializer(); + +class _$GHumanWithArgsDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GHumanWithArgsData, _$GHumanWithArgsData]; + @override + final String wireName = 'GHumanWithArgsData'; + + @override + Iterable serialize( + Serializers serializers, GHumanWithArgsData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.human; + if (value != null) { + result + ..add('human') + ..add(serializers.serialize(value, + specifiedType: const FullType(GHumanWithArgsData_human))); + } + return result; + } + + @override + GHumanWithArgsData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHumanWithArgsDataBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'human': + result.human.replace(serializers.deserialize(value, + specifiedType: const FullType(GHumanWithArgsData_human))! + as GHumanWithArgsData_human); + break; + } + } + + return result.build(); + } +} + +class _$GHumanWithArgsData_humanSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GHumanWithArgsData_human, + _$GHumanWithArgsData_human + ]; + @override + final String wireName = 'GHumanWithArgsData_human'; + + @override + Iterable serialize( + Serializers serializers, GHumanWithArgsData_human object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'name', + serializers.serialize(object.name, specifiedType: const FullType(String)), + ]; + Object? value; + value = object.height; + if (value != null) { + result + ..add('height') + ..add(serializers.serialize(value, + specifiedType: const FullType(double))); + } + return result; + } + + @override + GHumanWithArgsData_human deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHumanWithArgsData_humanBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case '__typename': + result.G__typename = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'name': + result.name = serializers.deserialize(value, + specifiedType: const FullType(String))! as String; + break; + case 'height': + result.height = serializers.deserialize(value, + specifiedType: const FullType(double)) as double?; + break; + } + } + + return result.build(); + } +} + +class _$GHumanWithArgsData extends GHumanWithArgsData { + @override + final String G__typename; + @override + final GHumanWithArgsData_human? human; + + factory _$GHumanWithArgsData( + [void Function(GHumanWithArgsDataBuilder)? updates]) => + (new GHumanWithArgsDataBuilder()..update(updates))._build(); + + _$GHumanWithArgsData._({required this.G__typename, this.human}) : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHumanWithArgsData', 'G__typename'); + } + + @override + GHumanWithArgsData rebuild( + void Function(GHumanWithArgsDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHumanWithArgsDataBuilder toBuilder() => + new GHumanWithArgsDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHumanWithArgsData && + G__typename == other.G__typename && + human == other.human; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, human.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHumanWithArgsData') + ..add('G__typename', G__typename) + ..add('human', human)) + .toString(); + } +} + +class GHumanWithArgsDataBuilder + implements Builder { + _$GHumanWithArgsData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GHumanWithArgsData_humanBuilder? _human; + GHumanWithArgsData_humanBuilder get human => + _$this._human ??= new GHumanWithArgsData_humanBuilder(); + set human(GHumanWithArgsData_humanBuilder? human) => _$this._human = human; + + GHumanWithArgsDataBuilder() { + GHumanWithArgsData._initializeBuilder(this); + } + + GHumanWithArgsDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _human = $v.human?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GHumanWithArgsData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHumanWithArgsData; + } + + @override + void update(void Function(GHumanWithArgsDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHumanWithArgsData build() => _build(); + + _$GHumanWithArgsData _build() { + _$GHumanWithArgsData _$result; + try { + _$result = _$v ?? + new _$GHumanWithArgsData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHumanWithArgsData', 'G__typename'), + human: _human?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'human'; + _human?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHumanWithArgsData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GHumanWithArgsData_human extends GHumanWithArgsData_human { + @override + final String G__typename; + @override + final String name; + @override + final double? height; + + factory _$GHumanWithArgsData_human( + [void Function(GHumanWithArgsData_humanBuilder)? updates]) => + (new GHumanWithArgsData_humanBuilder()..update(updates))._build(); + + _$GHumanWithArgsData_human._( + {required this.G__typename, required this.name, this.height}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHumanWithArgsData_human', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + name, r'GHumanWithArgsData_human', 'name'); + } + + @override + GHumanWithArgsData_human rebuild( + void Function(GHumanWithArgsData_humanBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHumanWithArgsData_humanBuilder toBuilder() => + new GHumanWithArgsData_humanBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHumanWithArgsData_human && + G__typename == other.G__typename && + name == other.name && + height == other.height; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, height.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHumanWithArgsData_human') + ..add('G__typename', G__typename) + ..add('name', name) + ..add('height', height)) + .toString(); + } +} + +class GHumanWithArgsData_humanBuilder + implements + Builder { + _$GHumanWithArgsData_human? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; + + double? _height; + double? get height => _$this._height; + set height(double? height) => _$this._height = height; + + GHumanWithArgsData_humanBuilder() { + GHumanWithArgsData_human._initializeBuilder(this); + } + + GHumanWithArgsData_humanBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _name = $v.name; + _height = $v.height; + _$v = null; + } + return this; + } + + @override + void replace(GHumanWithArgsData_human other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHumanWithArgsData_human; + } + + @override + void update(void Function(GHumanWithArgsData_humanBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHumanWithArgsData_human build() => _build(); + + _$GHumanWithArgsData_human _build() { + final _$result = _$v ?? + new _$GHumanWithArgsData_human._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GHumanWithArgsData_human', 'G__typename'), + name: BuiltValueNullFieldError.checkNotNull( + name, r'GHumanWithArgsData_human', 'name'), + height: height); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.req.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.req.gql.dart new file mode 100644 index 00000000..07044a79 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.req.gql.dart @@ -0,0 +1,45 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:end_to_end_test_tristate/variables/__generated__/human_with_args.ast.gql.dart' + as _i2; +import 'package:end_to_end_test_tristate/variables/__generated__/human_with_args.var.gql.dart' + as _i3; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'human_with_args.req.gql.g.dart'; + +abstract class GHumanWithArgs + implements Built { + GHumanWithArgs._(); + + factory GHumanWithArgs([Function(GHumanWithArgsBuilder b) updates]) = + _$GHumanWithArgs; + + static void _initializeBuilder(GHumanWithArgsBuilder b) => b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'HumanWithArgs', + ); + + _i3.GHumanWithArgsVars get vars; + _i1.Operation get operation; + static Serializer get serializer => + _$gHumanWithArgsSerializer; + + Map toJson() => (_i4.serializers.serializeWith( + GHumanWithArgs.serializer, + this, + ) as Map); + + static GHumanWithArgs? fromJson(Map json) => + _i4.serializers.deserializeWith( + GHumanWithArgs.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.req.gql.g.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.req.gql.g.dart new file mode 100644 index 00000000..4b085286 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.req.gql.g.dart @@ -0,0 +1,177 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'human_with_args.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gHumanWithArgsSerializer = + new _$GHumanWithArgsSerializer(); + +class _$GHumanWithArgsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GHumanWithArgs, _$GHumanWithArgs]; + @override + final String wireName = 'GHumanWithArgs'; + + @override + Iterable serialize(Serializers serializers, GHumanWithArgs object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: const FullType(_i3.GHumanWithArgsVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GHumanWithArgs deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GHumanWithArgsBuilder(); + + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current! as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'vars': + result.vars.replace(serializers.deserialize(value, + specifiedType: const FullType(_i3.GHumanWithArgsVars))! + as _i3.GHumanWithArgsVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GHumanWithArgs extends GHumanWithArgs { + @override + final _i3.GHumanWithArgsVars vars; + @override + final _i1.Operation operation; + + factory _$GHumanWithArgs([void Function(GHumanWithArgsBuilder)? updates]) => + (new GHumanWithArgsBuilder()..update(updates))._build(); + + _$GHumanWithArgs._({required this.vars, required this.operation}) + : super._() { + BuiltValueNullFieldError.checkNotNull(vars, r'GHumanWithArgs', 'vars'); + BuiltValueNullFieldError.checkNotNull( + operation, r'GHumanWithArgs', 'operation'); + } + + @override + GHumanWithArgs rebuild(void Function(GHumanWithArgsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHumanWithArgsBuilder toBuilder() => + new GHumanWithArgsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHumanWithArgs && + vars == other.vars && + operation == other.operation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHumanWithArgs') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GHumanWithArgsBuilder + implements Builder { + _$GHumanWithArgs? _$v; + + _i3.GHumanWithArgsVarsBuilder? _vars; + _i3.GHumanWithArgsVarsBuilder get vars => + _$this._vars ??= new _i3.GHumanWithArgsVarsBuilder(); + set vars(_i3.GHumanWithArgsVarsBuilder? vars) => _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GHumanWithArgsBuilder() { + GHumanWithArgs._initializeBuilder(this); + } + + GHumanWithArgsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GHumanWithArgs other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHumanWithArgs; + } + + @override + void update(void Function(GHumanWithArgsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHumanWithArgs build() => _build(); + + _$GHumanWithArgs _build() { + _$GHumanWithArgs _$result; + try { + _$result = _$v ?? + new _$GHumanWithArgs._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull( + operation, r'GHumanWithArgs', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GHumanWithArgs', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.dart new file mode 100644 index 00000000..c8edb3ee --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.dart @@ -0,0 +1,75 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'package:built_value/built_value.dart'; +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'human_with_args.var.gql.g.dart'; + +abstract class GHumanWithArgsVars + implements Built { + GHumanWithArgsVars._(); + + factory GHumanWithArgsVars([Function(GHumanWithArgsVarsBuilder b) updates]) = + _$GHumanWithArgsVars; + + String get id; + Map toJson() => (_i1.serializers.serializeWith( + GHumanWithArgsVars.serializer, + this, + ) as Map); + + static GHumanWithArgsVars? fromJson(Map json) => + _i1.serializers.deserializeWith( + GHumanWithArgsVars.serializer, + json, + ); + + @BuiltValueSerializer(custom: true, serializeNulls: true) + static Serializer get serializer => + GHumanWithArgsVarsSerializer(); +} + +class GHumanWithArgsVarsSerializer + extends StructuredSerializer { + final String wireName = 'GHumanWithArgsVars'; + + final Iterable types = const [GHumanWithArgsVars, _$GHumanWithArgsVars]; + + Iterable serialize( + Serializers serializers, + GHumanWithArgsVars object, { + FullType specifiedType = FullType.unspecified, + }) { + final result = []; + result.add('id'); + result.add(serializers.serialize(object.id, + specifiedType: const FullType(String))); + return result; + } + + GHumanWithArgsVars deserialize( + Serializers serializers, + Iterable serialized, { + FullType specifiedType = FullType.unspecified, + }) { + final builder = GHumanWithArgsVarsBuilder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + case 'id': + var fieldValue = serializers.deserialize(value, + specifiedType: const FullType(String)) as String; + builder.id = fieldValue; + break; + } + } + return builder.build(); + } +} diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.g.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.g.dart new file mode 100644 index 00000000..907174cc --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.g.dart @@ -0,0 +1,94 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'human_with_args.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +class _$GHumanWithArgsVars extends GHumanWithArgsVars { + @override + final String id; + + factory _$GHumanWithArgsVars( + [void Function(GHumanWithArgsVarsBuilder)? updates]) => + (new GHumanWithArgsVarsBuilder()..update(updates))._build(); + + _$GHumanWithArgsVars._({required this.id}) : super._() { + BuiltValueNullFieldError.checkNotNull(id, r'GHumanWithArgsVars', 'id'); + } + + @override + GHumanWithArgsVars rebuild( + void Function(GHumanWithArgsVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GHumanWithArgsVarsBuilder toBuilder() => + new GHumanWithArgsVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GHumanWithArgsVars && id == other.id; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GHumanWithArgsVars')..add('id', id)) + .toString(); + } +} + +class GHumanWithArgsVarsBuilder + implements Builder { + _$GHumanWithArgsVars? _$v; + + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; + + GHumanWithArgsVarsBuilder(); + + GHumanWithArgsVarsBuilder get _$this { + final $v = _$v; + if ($v != null) { + _id = $v.id; + _$v = null; + } + return this; + } + + @override + void replace(GHumanWithArgsVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GHumanWithArgsVars; + } + + @override + void update(void Function(GHumanWithArgsVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GHumanWithArgsVars build() => _build(); + + _$GHumanWithArgsVars _build() { + final _$result = _$v ?? + new _$GHumanWithArgsVars._( + id: BuiltValueNullFieldError.checkNotNull( + id, r'GHumanWithArgsVars', 'id')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test_tristate/lib/variables/create_custom_field.graphql b/codegen/end_to_end_test_tristate/lib/variables/create_custom_field.graphql new file mode 100644 index 00000000..d323ef49 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/create_custom_field.graphql @@ -0,0 +1,5 @@ + + +mutation CreateCustomField($input: CustomFieldInput!) { + createCustomField(input: $input) +} \ No newline at end of file diff --git a/codegen/end_to_end_test_tristate/lib/variables/create_review.graphql b/codegen/end_to_end_test_tristate/lib/variables/create_review.graphql new file mode 100644 index 00000000..73bec14d --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/create_review.graphql @@ -0,0 +1,7 @@ +mutation CreateReview($episode: Episode, $review: ReviewInput!) { + createReview(episode: $episode, review: $review) { + episode + stars + commentary + } +} diff --git a/codegen/end_to_end_test_tristate/lib/variables/human_with_args.graphql b/codegen/end_to_end_test_tristate/lib/variables/human_with_args.graphql new file mode 100644 index 00000000..a5296f47 --- /dev/null +++ b/codegen/end_to_end_test_tristate/lib/variables/human_with_args.graphql @@ -0,0 +1,6 @@ +query HumanWithArgs($id: ID!) { + human(id: $id) { + name + height + } +} diff --git a/codegen/end_to_end_test_tristate/pubspec.yaml b/codegen/end_to_end_test_tristate/pubspec.yaml new file mode 100644 index 00000000..2b12a118 --- /dev/null +++ b/codegen/end_to_end_test_tristate/pubspec.yaml @@ -0,0 +1,17 @@ +name: end_to_end_test_tristate +version: 0.0.1 +publish_to: none +description: Tests, not for publishing. Uses the tristate optionals version of codegen. +repository: https://github.com/gql-dart/gql +environment: + sdk: '>=3.0.0 <4.0.0' +dependencies: + built_collection: ^5.0.0 + built_value: ^8.0.6 + gql_exec: ^1.0.0 + gql_build: ^0.8.0 + gql_code_builder: ^0.7.1 +dev_dependencies: + build: ^2.0.0 + build_runner: ^2.0.0 + test: ^1.16.8 diff --git a/codegen/end_to_end_test_tristate/test/custom_serializers/operation_serializer_test.dart b/codegen/end_to_end_test_tristate/test/custom_serializers/operation_serializer_test.dart new file mode 100644 index 00000000..895679ff --- /dev/null +++ b/codegen/end_to_end_test_tristate/test/custom_serializers/operation_serializer_test.dart @@ -0,0 +1,29 @@ +import "package:test/test.dart"; +import "package:gql_exec/gql_exec.dart"; +import "package:gql_code_builder/src/serializers/operation_serializer.dart"; + +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_fragments.ast.gql.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart'; + +void main() { + group("Operation Type", () { + test('can be serialized / deserialized with operationName', () { + final operation = Operation( + document: document, + operationName: "HeroWithFragments", + ); + final json = serializers.serialize(operation); + final Operation deserialized = + serializers.deserializeWith(OperationSerializer(), json)!; + expect(deserialized, equals(operation)); + }); + + test('can be serialized / deserialized without operationName', () { + final operation = Operation(document: document); + final json = serializers.serialize(operation); + final Operation deserialized = + serializers.deserializeWith(OperationSerializer(), json)!; + expect(deserialized, equals(operation)); + }); + }); +} diff --git a/codegen/end_to_end_test_tristate/test/data/when_extension_test.dart b/codegen/end_to_end_test_tristate/test/data/when_extension_test.dart new file mode 100644 index 00000000..4fdc1cf9 --- /dev/null +++ b/codegen/end_to_end_test_tristate/test/data/when_extension_test.dart @@ -0,0 +1,146 @@ +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.dart'; +import 'package:test/test.dart'; + +void main() { + final human = GheroFieldsFragmentData__asHuman((d) => d + ..id = "obiwan" + ..name = "Obiwan" + ..homePlanet = "Stewjon" + ..friends.addAll([ + GheroFieldsFragmentData__asHuman_friends__asDroid((b) => b + ..G__typename = "Droid" + ..id = "r2d2" + ..name = "R2-D2" + ..primaryFunction = "Astromech"), + GheroFieldsFragmentData__asHuman_friends__asHuman((b) => b + ..G__typename = "Human" + ..id = "luke" + ..name = "Luke" + ..homePlanet = "Tattoine"), + ])); + + final droid = GheroFieldsFragmentData__asDroid((d) => d + ..id = "r2d2" + ..name = "R2-D2" + ..primaryFunction = "Astromech"); + + group("when()", () { + test("can call when on humans", () { + bool wasCalled = false; + human.when( + human: (h) { + wasCalled = true; + }, + droid: (_) => fail("should not be called"), + orElse: () => fail("should not be called")); + + expect(wasCalled, isTrue); + }); + + test("can call when on droids", () { + bool wasCalled = false; + droid.when( + human: (_) => fail("should not be called"), + droid: (d) { + wasCalled = true; + }, + orElse: () => fail("should not be called")); + + expect(wasCalled, isTrue); + }); + + test("when returns result", () { + final primaryFunction = droid.when( + human: (_) => fail("should not be called"), + droid: (d) => d.primaryFunction, + orElse: () => fail("should not be called")); + + expect(primaryFunction, "Astromech"); + }); + + test("unexpected typeName calls orElse", () { + final animal = human.rebuild((b) => b..G__typename = "Animal"); + + bool wasCalled = false; + + animal.when( + human: (_) {}, + droid: (_) {}, + orElse: () { + wasCalled = true; + }); + + expect(wasCalled, isTrue); + }); + + test("works on subtypes", () { + final droidFriend = human.friends!.first!; + + bool droidWasCalled = false; + droidFriend.when( + droid: (d) { + droidWasCalled = true; + }, + human: (_) => fail("should not be called"), + orElse: () => fail("should not be called")); + + final humanFriend = human.friends!.last!; + + bool humanWasCalled = false; + humanFriend.when( + human: (h) { + humanWasCalled = true; + }, + droid: (_) => fail("should not be called"), + orElse: () => fail("should not be called")); + + expect(droidWasCalled, isTrue); + expect(humanWasCalled, isTrue); + }); + }); + + group("maybeWhen()", () { + test("can call maybeWhen on humans", () { + bool wasCalled = false; + human.maybeWhen( + human: (h) { + wasCalled = true; + }, + orElse: () => fail("should not be called")); + + expect(wasCalled, isTrue); + }); + + test("can call maybeWhen on droids", () { + bool wasCalled = false; + droid.maybeWhen( + droid: (d) { + wasCalled = true; + }, + orElse: () => fail("should not be called")); + + expect(wasCalled, isTrue); + }); + + test("calls orElse when not matching", () { + bool wasCalled = false; + droid.maybeWhen(orElse: () { + wasCalled = true; + }); + + expect(wasCalled, isTrue); + }); + + test("unexpected typeName calls orElse", () { + final animal = human.rebuild((b) => b..G__typename = "Animal"); + + bool wasCalled = false; + + animal.maybeWhen(orElse: () { + wasCalled = true; + }); + + expect(wasCalled, isTrue); + }); + }); +} diff --git a/codegen/end_to_end_test_tristate/test/operation/aliases_test.dart b/codegen/end_to_end_test_tristate/test/operation/aliases_test.dart new file mode 100644 index 00000000..bcc28627 --- /dev/null +++ b/codegen/end_to_end_test_tristate/test/operation/aliases_test.dart @@ -0,0 +1,38 @@ +import "package:test/test.dart"; + +import 'package:end_to_end_test_tristate/aliases/__generated__/aliased_hero.data.gql.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart'; + +void main() { + group("Aliases", () { + test('can be instantiated with aliased fields', () { + GAliasedHeroData( + (b) => b + ..empireHero.G__typename = "Human" + ..empireHero.id = "leia" + ..empireHero.name = "Leia" + ..empireHero.from.add(GEpisode.NEWHOPE), + ); + }); + + test('can be serialized with aliased fields', () { + final data = GAliasedHeroData( + (b) => b + ..empireHero.G__typename = "Human" + ..empireHero.id = "leia" + ..empireHero.name = "Leia" + ..empireHero.from.add(GEpisode.NEWHOPE), + ); + final json = { + "__typename": "Query", + "empireHero": { + "__typename": "Human", + "id": "leia", + "name": "Leia", + "from": ["NEWHOPE"], + }, + }; + expect(data.toJson(), equals(json)); + }); + }); +} diff --git a/codegen/end_to_end_test_tristate/test/operation/fragments_inline_nesting_test.dart b/codegen/end_to_end_test_tristate/test/operation/fragments_inline_nesting_test.dart new file mode 100644 index 00000000..8f63853d --- /dev/null +++ b/codegen/end_to_end_test_tristate/test/operation/fragments_inline_nesting_test.dart @@ -0,0 +1,98 @@ +import "package:test/test.dart"; + +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.dart'; + +void main() { + group("Fragments with InlineFragments for different sub-Types", () { + test('can deserialize correctly from sub-Typed data', () { + final jsonHuman = { + "__typename": "Human", + "id": "luke", + "name": "Luke", + "homePlanet": "Tattoine", + "friends": [ + { + "__typename": "Droid", + "id": "r2d2", + "name": "R2-D2", + "primaryFunction": "Astromech" + }, + { + "__typename": "Human", + "id": "han", + "name": "Han Solo", + "homePlanet": "Nerf", + }, + ], + }; + + final gqlHuman = GheroFieldsFragmentData__asHuman.fromJson(jsonHuman); + + expect(gqlHuman?.id, equals("luke")); + expect(gqlHuman?.name, equals("Luke")); + expect(gqlHuman?.homePlanet, equals("Tattoine")); + + final gqlHuman_droidFriends = gqlHuman?.friends + ?.whereType(); + + expect(gqlHuman_droidFriends?.first.G__typename, equals("Droid")); + expect(gqlHuman_droidFriends?.first.id, equals("r2d2")); + expect(gqlHuman_droidFriends?.first.name, equals("R2-D2")); + expect(gqlHuman_droidFriends?.first.primaryFunction, equals("Astromech")); + + final gqlHuman_humanFriends = gqlHuman?.friends + ?.whereType(); + + expect(gqlHuman_humanFriends?.first.id, equals("han")); + expect(gqlHuman_humanFriends?.first.name, equals("Han Solo")); + expect(gqlHuman_humanFriends?.first.homePlanet, equals("Nerf")); + }); + + test('can be serialized and deserialized', () { + final obiwan = GheroFieldsFragmentData__asHuman( + (d) => d + ..G__typename = "Human" + ..id = "obiwan" + ..name = "Obiwan" + ..homePlanet = "Stewjon" + ..friends.addAll([ + GheroFieldsFragmentData__asHuman_friends__asDroid( + (b) => b + ..G__typename = "Droid" + ..id = "r2d2" + ..name = "R2-D2" + ..primaryFunction = "Astromech", + ), + GheroFieldsFragmentData__asHuman_friends__asHuman((b) => b + ..G__typename = "Human" + ..id = "luke" + ..name = "Luke" + ..homePlanet = "Tattoine"), + ]), + ); + + final json = { + "__typename": "Human", + "id": "obiwan", + "name": "Obiwan", + "homePlanet": "Stewjon", + "friends": [ + { + "__typename": "Droid", + "id": "r2d2", + "name": "R2-D2", + "primaryFunction": "Astromech" + }, + { + "__typename": "Human", + "id": "luke", + "name": "Luke", + "homePlanet": "Tattoine", + }, + ], + }; + + expect(obiwan.toJson(), equals(json)); + }); + }); +} diff --git a/codegen/end_to_end_test_tristate/test/operation/fragments_test.dart b/codegen/end_to_end_test_tristate/test/operation/fragments_test.dart new file mode 100644 index 00000000..36b68915 --- /dev/null +++ b/codegen/end_to_end_test_tristate/test/operation/fragments_test.dart @@ -0,0 +1,65 @@ +import "package:test/test.dart"; + +import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_fragments.data.gql.dart'; + +void main() { + group("Fragments", () { + test('includes the fragment fields', () { + GHeroWithFragmentsData( + (d) => d + ..hero.G__typename = "Human" + ..hero.id = "leia" + ..hero.name = "Leia" + ..hero.friendsConnection.totalCount = 1 + ..hero.friendsConnection.edges.add( + GHeroWithFragmentsData_hero_friendsConnection_edges( + (b) => b + ..node.G__typename = "Human" + ..node.name = "Luke", + ), + ), + ); + }); + + test('can be serialized and deserialized', () { + final leia = GHeroWithFragmentsData( + (d) => d + ..hero.G__typename = "Human" + ..hero.id = "leia" + ..hero.name = "Leia" + ..hero.friendsConnection.totalCount = 1 + ..hero.friendsConnection.edges.add( + GHeroWithFragmentsData_hero_friendsConnection_edges( + (b) => b + ..node.G__typename = "Human" + ..node.name = "Luke", + ), + ), + ); + + final json = { + "__typename": "Query", + "hero": { + "__typename": "Human", + "id": "leia", + "name": "Leia", + "friendsConnection": { + "__typename": "FriendsConnection", + "totalCount": 1, + "edges": [ + { + "__typename": "FriendsEdge", + "node": { + "__typename": "Human", + "name": "Luke", + }, + }, + ], + }, + }, + }; + + expect(leia.toJson(), equals(json)); + }); + }); +} diff --git a/codegen/end_to_end_test_tristate/test/operation/interfaces_test.dart b/codegen/end_to_end_test_tristate/test/operation/interfaces_test.dart new file mode 100644 index 00000000..a3af21b6 --- /dev/null +++ b/codegen/end_to_end_test_tristate/test/operation/interfaces_test.dart @@ -0,0 +1,67 @@ +import "package:test/test.dart"; + +import 'package:end_to_end_test_tristate/interfaces/__generated__/hero_for_episode.data.gql.dart'; + +void main() { + group("Interfaces", () { + test('data with base class type can be instantiated', () { + GHeroForEpisodeData( + (b) => b + ..hero = GHeroForEpisodeData_hero__base( + (b) => b + ..G__typename = "Hero" + ..name = "Luke", + ), + ); + ; + }); + + test('data with inline fragment types can be instantiated', () { + GHeroForEpisodeData( + (b) => b + ..hero = GHeroForEpisodeData_hero__asDroid( + (b) => b + ..G__typename = "Droid" + ..primaryFunction = "beep" + ..name = "r2", + ), + ); + }); + + test('types without inline fragments get deserialized as base type', () { + final data = { + "__typename": "Sith", + "name": "Darth Maul", + }; + final deserialized = GHeroForEpisodeData_hero.fromJson(data); + expect(deserialized, TypeMatcher()); + }); + + test('data is deserialized into correct type', () { + final data = { + "__typename": "Droid", + "primaryFunction": "beep", + "name": "r2", + }; + final deserialized = GHeroForEpisodeData_hero.fromJson(data); + expect(deserialized, TypeMatcher()); + }); + + test('data is serialized and deserialized correctly', () { + final droid = GHeroForEpisodeData_hero__asDroid( + (b) => b + ..G__typename = "Droid" + ..primaryFunction = "beep" + ..name = "r2", + ); + final json = { + "__typename": "Droid", + "primaryFunction": "beep", + "name": "r2", + }; + droid.toJson(); + expect(droid.toJson(), equals(json)); + expect(GHeroForEpisodeData_hero__asDroid.fromJson(json), equals(droid)); + }); + }); +} diff --git a/codegen/end_to_end_test_tristate/test/operation/requests_test.dart b/codegen/end_to_end_test_tristate/test/operation/requests_test.dart new file mode 100644 index 00000000..35401076 --- /dev/null +++ b/codegen/end_to_end_test_tristate/test/operation/requests_test.dart @@ -0,0 +1,41 @@ +import "package:test/test.dart"; +import "package:gql/language.dart"; + +import 'package:end_to_end_test_tristate/variables/__generated__/human_with_args.req.gql.dart'; +import 'package:end_to_end_test_tristate/variables/__generated__/human_with_args.ast.gql.dart' + as human_with_args_ast; +import 'package:end_to_end_test_tristate/no_vars/__generated__/hero_no_vars.req.gql.dart'; +import 'package:end_to_end_test_tristate/no_vars/__generated__/hero_no_vars.ast.gql.dart' + as hero_no_args_ast; + +void main() { + group("Requests", () { + test('request objects can be serialized / deserialized', () { + final req = GHumanWithArgs((b) => b..vars.id = "123"); + final json = { + "operation": { + "operationName": "HumanWithArgs", + "document": printNode(human_with_args_ast.document), + }, + "vars": { + "id": "123", + }, + }; + expect(req.toJson(), equals(json)); + expect(GHumanWithArgs.fromJson(json), req); + }); + + test('requests can be initialized without vars', () { + final req = GHeroNoVars(); + final json = { + "operation": { + "operationName": "HeroNoVars", + "document": printNode(hero_no_args_ast.document), + }, + "vars": {}, + }; + expect(req.toJson(), equals(json)); + expect(GHeroNoVars.fromJson(json), req); + }); + }); +} diff --git a/codegen/end_to_end_test_tristate/test/operation/variables_test.dart b/codegen/end_to_end_test_tristate/test/operation/variables_test.dart new file mode 100644 index 00000000..361c4410 --- /dev/null +++ b/codegen/end_to_end_test_tristate/test/operation/variables_test.dart @@ -0,0 +1,49 @@ +import 'package:gql_exec/value.dart'; +import "package:test/test.dart"; + +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart'; +import 'package:end_to_end_test_tristate/variables/__generated__/human_with_args.var.gql.dart'; +import 'package:end_to_end_test_tristate/variables/__generated__/create_review.var.gql.dart'; + +void main() { + group("Basic Args", () { + final args = GHumanWithArgsVars((b) => b..id = "123"); + final json = { + "id": "123", + }; + + test('basic args object can be serialized / deserialized', () { + expect(args.toJson(), equals(json)); + expect(GHumanWithArgsVars.fromJson(json), args); + }); + }); + + group("Complex Args", () { + final args = GCreateReviewVars((b) => b + ..episode = Value.present(GEpisode.EMPIRE) + ..review.stars = 5 + ..review.commentary = Value.present("this was amazing!!!") + ..review.favorite_color = Value.present(GColorInput((b) => b + ..blue = 255 + ..green = 120 + ..red = 80))); + + final json = { + "episode": "EMPIRE", + "review": { + "stars": 5, + "commentary": "this was amazing!!!", + "favorite_color": { + "blue": 255, + "green": 120, + "red": 80, + }, + }, + }; + + test('complex args object can be serialized / deserialized', () { + expect(args.toJson(), equals(json)); + expect(GCreateReviewVars.fromJson(json), args); + }); + }); +} diff --git a/codegen/end_to_end_test_tristate/test/schema/enums_test.dart b/codegen/end_to_end_test_tristate/test/schema/enums_test.dart new file mode 100644 index 00000000..144aee08 --- /dev/null +++ b/codegen/end_to_end_test_tristate/test/schema/enums_test.dart @@ -0,0 +1,24 @@ +import 'package:built_value/serializer.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart'; +import "package:test/test.dart"; + +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart'; + +void main() { + group("Enums", () { + test('produce the correct string', () { + expect(GEpisode.EMPIRE.toString(), equals("EMPIRE")); + }); + + test('are correct type', () { + expect(GEpisode.EMPIRE, TypeMatcher()); + }); + + test('fallback of LengthUnit to METER works', () { + expect( + serializers.deserialize("UNKNOWN_UNIT", + specifiedType: FullType(GLengthUnit)), + equals(GLengthUnit.METER)); + }); + }); +} diff --git a/codegen/end_to_end_test_tristate/test/schema/input_test.dart b/codegen/end_to_end_test_tristate/test/schema/input_test.dart new file mode 100644 index 00000000..8107b0ad --- /dev/null +++ b/codegen/end_to_end_test_tristate/test/schema/input_test.dart @@ -0,0 +1,37 @@ +import 'package:gql_exec/value.dart'; +import "package:test/test.dart"; + +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart'; + +void main() { + group("Inputs", () { + test('can be instantiated', () { + GReviewInput((b) => b + ..stars = 4 + ..commentary = Value.present("This was a great movie!") + ..favorite_color = Value.present(GColorInput((b) => b + ..red = 225 + ..blue = 255 + ..green = 123))); + }); + + test('can be serialized and deserialized', () { + final input = GReviewInput((b) => b + ..stars = 4 + ..favorite_color = Value.present(GColorInput((b) => b + ..red = 225 + ..blue = 255 + ..green = 123))); + final json = { + "stars": 4, + "favorite_color": { + "red": 225, + "blue": 255, + "green": 123, + }, + }; + expect(input.toJson(), equals(json)); + expect(GReviewInput.fromJson(json), equals(input)); + }); + }); +} diff --git a/codegen/end_to_end_test_tristate/test/schema/scalars_test.dart b/codegen/end_to_end_test_tristate/test/schema/scalars_test.dart new file mode 100644 index 00000000..5f501a36 --- /dev/null +++ b/codegen/end_to_end_test_tristate/test/schema/scalars_test.dart @@ -0,0 +1,135 @@ +import 'package:built_collection/built_collection.dart'; +import 'package:gql_exec/value.dart'; +import "package:test/test.dart"; + +import 'package:end_to_end_test_tristate/graphql/__generated__/schema.schema.gql.dart'; +import 'package:end_to_end_test_tristate/graphql/__generated__/serializers.gql.dart'; +import 'package:end_to_end_test_tristate/scalars/__generated__/review_with_date.data.gql.dart'; +import 'package:end_to_end_test_tristate/scalars/__generated__/review_with_date.var.gql.dart'; +import 'package:end_to_end_test_tristate/custom_field.dart'; +import 'package:end_to_end_test_tristate/custom_field_serializer.dart'; + +void main() { + group("Custom scalars from non-standard dart types", () { + final customField = CustomField('hi', 4.5, { + 'subfield': ['some', 'substrings'] + }); + + test('correctly serializes and deserializes', () { + expect( + serializers.deserializeWith( + CustomFieldSerializer(), + customField.toJson(), + ), + equals(customField), + ); + expect( + serializers.serializeWith(CustomFieldSerializer(), customField), + equals( + customField.toJson(), + ), + ); + }); + + final data = GReviewWithDateData((b) => b + ..createReview.custom.addAll([customField]) + ..createReview.stars = 1); + + test('can use in GraphQL operation data', () { + expect(data.createReview!.custom.first, equals(customField)); + expect( + data.createReview!.toJson()['custom'].first, + equals(customField.toJson()), + ); + }); + }); + + group("Custom scalars without user overrides", () { + final isoString = "2020-06-12T13:23:59Z"; + final scalar = GISODate(isoString); + + test('correctly serializes and deserializes', () { + expect(serializers.deserializeWith(GISODate.serializer, isoString), + equals(scalar)); + expect(serializers.serializeWith(GISODate.serializer, scalar), + equals(isoString)); + }); + }); + + group("Custom scalars in input types", () { + final input = GReviewInput((b) => b + ..stars = 4 + ..seenOn = Value.present( + BuiltList([DateTime.fromMillisecondsSinceEpoch(1591892597000)]), + )); + test('correctly overrides scalars in input types', () { + expect((input.seenOn! as PresentValue).value!.first, + TypeMatcher()); + }); + + test('can be serialized and deserialized with custom serializer', () { + final json = { + "stars": 4, + "seenOn": [1591892597000], + }; + expect(input.toJson(), equals(json)); + expect(GReviewInput.fromJson(json), equals(input)); + }); + }); + + group("Custom scalars in var types", () { + final vars = GReviewWithDateVars( + (b) => b + ..review.stars = 4 + ..createdAt = + Value.present(DateTime.fromMillisecondsSinceEpoch(1591892597000)), + ); + + test('correctly overrides scalars in variable types', () { + expect((vars.createdAt! as PresentValue).value, TypeMatcher()); + }); + + test('can be serialized and deserialized with custom serializer', () { + final json = { + "review": { + "stars": 4, + }, + "createdAt": 1591892597000, + }; + expect(vars.toJson(), equals(json)); + expect(GReviewWithDateVars.fromJson(json), equals(vars)); + }); + }); + + group("Custom scalars in data types", () { + final data = GReviewWithDateData( + (b) => b + ..createReview.stars = 1 + ..createReview + .seenOn + .add(DateTime.fromMillisecondsSinceEpoch(1591892597000)) + ..createReview.createdAt = + DateTime.fromMillisecondsSinceEpoch(1591892597000), + ); + + test('correctly overrides scalars in data types', () { + expect(data.createReview!.seenOn.first, TypeMatcher()); + expect(data.createReview!.createdAt, TypeMatcher()); + }); + + test('can be serialized and deserialized with custom serializer', () { + final json = { + "__typename": "Mutation", + "createReview": { + "__typename": "Review", + "stars": 1, + "seenOn": [1591892597000], + "createdAt": 1591892597000, + "custom": [], + }, + }; + expect(data.toJson(), equals(json)); + expect(GReviewWithDateData.fromJson(json), equals(data)); + }); + }); +} diff --git a/codegen/gql_build/lib/gql_build.dart b/codegen/gql_build/lib/gql_build.dart index 9e8efd8c..cb4bf28b 100644 --- a/codegen/gql_build/lib/gql_build.dart +++ b/codegen/gql_build/lib/gql_build.dart @@ -43,21 +43,21 @@ Builder varBuilder( BuilderOptions options, ) => VarBuilder( - AssetId.parse( - options.config["schema"] as String, - ), - typeOverrideMap(options.config["type_overrides"]), - ); + AssetId.parse( + options.config["schema"] as String, + ), + typeOverrideMap(options.config["type_overrides"]), + triStateOptionalsConfig(options.config)); /// Builds GraphQL schema types Builder schemaBuilder( BuilderOptions options, ) => SchemaBuilder( - typeOverrideMap(options.config["type_overrides"]), - enumFallbackConfig(options.config), - generatePossibleTypesConfig(options.config), - ); + typeOverrideMap(options.config["type_overrides"]), + enumFallbackConfig(options.config), + generatePossibleTypesConfig(options.config), + triStateOptionalsConfig(options.config)); /// Builds an aggregate Serlializers object for [built_value]s /// diff --git a/codegen/gql_build/lib/src/schema_builder.dart b/codegen/gql_build/lib/src/schema_builder.dart index d85096f9..50659478 100644 --- a/codegen/gql_build/lib/src/schema_builder.dart +++ b/codegen/gql_build/lib/src/schema_builder.dart @@ -4,6 +4,7 @@ import "package:build/build.dart"; import "package:code_builder/code_builder.dart"; import "package:gql_build/src/allocators/gql_allocator.dart"; import "package:gql_code_builder/schema.dart"; +import "package:gql_code_builder/var.dart"; import "package:path/path.dart"; import "./config.dart"; @@ -14,9 +15,10 @@ class SchemaBuilder implements Builder { final Map typeOverrides; final EnumFallbackConfig enumFallbackConfig; final bool generatePossibleTypesMap; + final TriStateValueConfig triStateValueConfig; SchemaBuilder(this.typeOverrides, this.enumFallbackConfig, - this.generatePossibleTypesMap); + this.generatePossibleTypesMap, this.triStateValueConfig); @override Map> get buildExtensions => { @@ -41,9 +43,14 @@ class SchemaBuilder implements Builder { ); final library = buildSchemaLibrary( - doc, basename(generatedPartUrl), typeOverrides, enumFallbackConfig, - generatePossibleTypesMap: generatePossibleTypesMap, - allocator: allocator); + doc, + basename(generatedPartUrl), + typeOverrides, + enumFallbackConfig, + generatePossibleTypesMap: generatePossibleTypesMap, + allocator: allocator, + triStateValueConfig: triStateValueConfig, + ); return writeDocument( library, buildStep, schemaExtension, schemaUrl, allocator); diff --git a/codegen/gql_build/lib/src/utils/config.dart b/codegen/gql_build/lib/src/utils/config.dart index 6afbfe2b..bccbb848 100644 --- a/codegen/gql_build/lib/src/utils/config.dart +++ b/codegen/gql_build/lib/src/utils/config.dart @@ -1,6 +1,7 @@ import "package:code_builder/code_builder.dart"; import "package:gql_code_builder/data.dart"; import "package:gql_code_builder/schema.dart"; +import "package:gql_code_builder/var.dart"; import "package:yaml/yaml.dart"; Map typeOverrideMap(dynamic typeOverrideConfig) { @@ -72,3 +73,15 @@ Map enumFallbackMap(final dynamic enumFallbacks) { } return {}; } + +TriStateValueConfig triStateOptionalsConfig(Map config) { + final configValue = config["tristate_optionals"]; + + if (configValue is bool) { + return configValue + ? TriStateValueConfig.onAllNullableFields + : TriStateValueConfig.never; + } + + return TriStateValueConfig.never; +} diff --git a/codegen/gql_build/lib/src/var_builder.dart b/codegen/gql_build/lib/src/var_builder.dart index 8733b6b5..bbd1317c 100644 --- a/codegen/gql_build/lib/src/var_builder.dart +++ b/codegen/gql_build/lib/src/var_builder.dart @@ -14,10 +14,12 @@ import "./utils/writer.dart"; class VarBuilder implements Builder { final AssetId schemaId; final Map typeOverrides; + final TriStateValueConfig triStateValueConfig; VarBuilder( this.schemaId, this.typeOverrides, + this.triStateValueConfig, ); @override @@ -42,8 +44,14 @@ class VarBuilder implements Builder { schemaUrl, ); - final library = buildVarLibrary(doc, addTypenames(schema), - basename(generatedPartUrl), typeOverrides, allocator); + final library = buildVarLibrary( + doc, + addTypenames(schema), + basename(generatedPartUrl), + typeOverrides, + allocator, + triStateValueConfig, + ); return writeDocument( library, diff --git a/codegen/gql_code_builder/lib/schema.dart b/codegen/gql_code_builder/lib/schema.dart index 99da105a..4b2a9d21 100644 --- a/codegen/gql_code_builder/lib/schema.dart +++ b/codegen/gql_code_builder/lib/schema.dart @@ -4,18 +4,17 @@ import "package:gql_code_builder/source.dart"; import "package:gql_code_builder/src/config/enum_fallback_config.dart"; import "package:gql_code_builder/src/schema.dart"; import "package:gql_code_builder/src/utils/possible_types.dart"; +import "package:gql_code_builder/var.dart"; export "package:gql_code_builder/src/config/enum_fallback_config.dart"; Library buildSchemaLibrary(SourceNode schemaSource, String partUrl, Map typeOverrides, EnumFallbackConfig enumFallbackConfig, - {bool generatePossibleTypesMap = false, Allocator? allocator}) { - final lib = buildSchema( - schemaSource, - typeOverrides, - enumFallbackConfig, - allocator ?? Allocator(), - ) as Library; + {bool generatePossibleTypesMap = false, + Allocator? allocator, + TriStateValueConfig triStateValueConfig = TriStateValueConfig.never}) { + final lib = buildSchema(schemaSource, typeOverrides, enumFallbackConfig, + allocator ?? Allocator(), triStateValueConfig) as Library; final Code? possibleTypes; if (generatePossibleTypesMap && lib.body.isNotEmpty) { diff --git a/codegen/gql_code_builder/lib/src/common.dart b/codegen/gql_code_builder/lib/src/common.dart index eee35aba..8d4be055 100644 --- a/codegen/gql_code_builder/lib/src/common.dart +++ b/codegen/gql_code_builder/lib/src/common.dart @@ -2,6 +2,7 @@ import "package:built_collection/built_collection.dart"; import "package:code_builder/code_builder.dart"; import "package:collection/collection.dart"; import "package:gql/ast.dart"; +import "package:gql_code_builder/var.dart"; import "../source.dart"; @@ -188,6 +189,8 @@ Method buildOptionalGetter({ String? typeRefPrefix, bool built = true, bool isOverride = false, + TriStateValueConfig useTriStateValueForNullableTypes = + TriStateValueConfig.never, }) { final baseGetter = buildGetter( nameNode: nameNode, @@ -199,7 +202,11 @@ Method buildOptionalGetter({ isOverride: isOverride, ); - if (typeNode.isNonNull) return baseGetter; + if (typeNode.isNonNull || + useTriStateValueForNullableTypes == TriStateValueConfig.never) { + return baseGetter; + } + ; final optionalGetter = baseGetter.rebuild((b) => b ..returns = TypeReference((b2) => b2 diff --git a/codegen/gql_code_builder/lib/src/schema.dart b/codegen/gql_code_builder/lib/src/schema.dart index e940b570..e486fbed 100644 --- a/codegen/gql_code_builder/lib/src/schema.dart +++ b/codegen/gql_code_builder/lib/src/schema.dart @@ -14,6 +14,7 @@ Spec? buildSchema( Map typeOverrides, EnumFallbackConfig enumFallbackConfig, Allocator allocator, + TriStateValueConfig triStateValueConfig, ) => schemaSource.document .accept( @@ -22,6 +23,7 @@ Spec? buildSchema( typeOverrides, enumFallbackConfig, allocator, + triStateValueConfig, ), ) ?.first; @@ -32,9 +34,10 @@ class _SchemaBuilderVisitor extends SimpleVisitor?> { final EnumFallbackConfig enumFallbackConfig; final Allocator allocator; + final TriStateValueConfig triStateValueConfig; const _SchemaBuilderVisitor(this.schemaSource, this.typeOverrides, - this.enumFallbackConfig, this.allocator); + this.enumFallbackConfig, this.allocator, this.triStateValueConfig); @override List visitDocumentNode( @@ -54,14 +57,17 @@ class _SchemaBuilderVisitor extends SimpleVisitor?> { List visitInputObjectTypeDefinitionNode( InputObjectTypeDefinitionNode node, ) { - final inputClass = buildInputClass( - node, - schemaSource, - typeOverrides, - ); - final serializer = nullAwareJsonSerializerClass( - inputClass, allocator, schemaSource, typeOverrides); - return [inputClass, serializer]; + final inputClass = + buildInputClass(node, schemaSource, typeOverrides, triStateValueConfig); + + return switch (triStateValueConfig) { + TriStateValueConfig.never => [inputClass], + TriStateValueConfig.onAllNullableFields => [ + inputClass, + nullAwareJsonSerializerClass( + inputClass, allocator, schemaSource, typeOverrides) + ], + }; } @override diff --git a/codegen/gql_code_builder/lib/src/schema/input.dart b/codegen/gql_code_builder/lib/src/schema/input.dart index 4ce965d8..0b4cdea1 100644 --- a/codegen/gql_code_builder/lib/src/schema/input.dart +++ b/codegen/gql_code_builder/lib/src/schema/input.dart @@ -10,6 +10,7 @@ List buildInputClasses( SourceNode schemaSource, Map typeOverrides, Allocator allocator, + TriStateValueConfig triStateValueConfig, ) => schemaSource.document.definitions .whereType() @@ -18,6 +19,7 @@ List buildInputClasses( node, schemaSource, typeOverrides, + triStateValueConfig, ); final serializer = nullAwareJsonSerializerClass( inputClass, allocator, schemaSource, typeOverrides); @@ -28,6 +30,7 @@ Class buildInputClass( InputObjectTypeDefinitionNode node, SourceNode schemaSource, Map typeOverrides, + TriStateValueConfig triStateValueConfig, ) => builtClass( name: node.name.value, @@ -37,10 +40,13 @@ Class buildInputClass( typeNode: node.type, schemaSource: schemaSource, typeOverrides: typeOverrides, + useTriStateValueForNullableTypes: triStateValueConfig, ), ), - hasCustomSerializer: true, + hasCustomSerializer: + triStateValueConfig == TriStateValueConfig.onAllNullableFields, methods: [ - nullAwareJsonSerializerField(node, "G${node.name.value}"), + if (triStateValueConfig == TriStateValueConfig.onAllNullableFields) + nullAwareJsonSerializerField(node, "G${node.name.value}"), ], ); diff --git a/codegen/gql_code_builder/lib/var.dart b/codegen/gql_code_builder/lib/var.dart index 3569edbf..1e099155 100644 --- a/codegen/gql_code_builder/lib/var.dart +++ b/codegen/gql_code_builder/lib/var.dart @@ -8,12 +8,15 @@ import "./src/common.dart"; import "./src/frag_vars.dart"; Library buildVarLibrary( - SourceNode docSource, - SourceNode schemaSource, - String partUrl, - Map typeOverrides, - Allocator allocator, -) { + SourceNode docSource, + SourceNode schemaSource, + String partUrl, + Map typeOverrides, + Allocator allocator, + TriStateValueConfig useTriStateValueForNullableTypes) { + final hasCustomSerializer = useTriStateValueForNullableTypes == + TriStateValueConfig.onAllNullableFields; + final operationVarClasses = docSource.document.definitions .whereType() .map((op) => builtClass( @@ -24,11 +27,19 @@ Library buildVarLibrary( typeNode: node.type, schemaSource: schemaSource, typeOverrides: typeOverrides, + useTriStateValueForNullableTypes: + useTriStateValueForNullableTypes, ), ), - hasCustomSerializer: true, + hasCustomSerializer: hasCustomSerializer, + initializers: switch (useTriStateValueForNullableTypes) { + TriStateValueConfig.onAllNullableFields => + _varClassValueInitializers(op), + TriStateValueConfig.never => {}, + }, methods: [ - nullAwareJsonSerializerField(op, "G${op.name!.value}Vars"), + if (hasCustomSerializer) + nullAwareJsonSerializerField(op, "G${op.name!.value}Vars"), ])) .toList(); @@ -57,9 +68,10 @@ Library buildVarLibrary( typeOverrides: typeOverrides, ), ), - hasCustomSerializer: true, + hasCustomSerializer: hasCustomSerializer, methods: [ - nullAwareJsonSerializerField(frag, "G${frag.name.value}Vars"), + if (hasCustomSerializer) + nullAwareJsonSerializerField(frag, "G${frag.name.value}Vars"), ], ); }).toList(); @@ -70,24 +82,36 @@ Library buildVarLibrary( ..body.addAll([ ...operationVarClasses, ...fragmentVarClasses, - for (final op in operationVarClasses) - nullAwareJsonSerializerClass( - op, - allocator, - schemaSource, - typeOverrides, - ), - for (final frag in fragmentVarClasses) - nullAwareJsonSerializerClass( - frag, - allocator, - schemaSource, - typeOverrides, - ), + if (hasCustomSerializer) ...[ + for (final op in operationVarClasses) + nullAwareJsonSerializerClass( + op, + allocator, + schemaSource, + typeOverrides, + ), + for (final frag in fragmentVarClasses) + nullAwareJsonSerializerClass( + frag, + allocator, + schemaSource, + typeOverrides, + ), + ] ]), ); } +Map _varClassValueInitializers( + OperationDefinitionNode op) => + { + for (final node + in op.variableDefinitions.where((element) => !element.type.isNonNull)) + identifier(node.variable.name.value): + refer("AbsentValue", "package:gql_exec/value.dart") + .constInstance(const []) + }; + Method nullAwareJsonSerializerField(Node op, String className) => Method((b) => b ..annotations.add(CodeExpression( @@ -169,8 +193,15 @@ Code _serializerBody(Class base, Allocator allocator, SourceNode schemaSource, Map typeOverrides) { final vars = []; - for (final field in base.methods - .where((field) => !field.static && field.type == MethodType.getter)) { + final fields = base.methods + .where((field) => field.type == MethodType.getter && !field.static) + .toList(); + + if (fields.isEmpty) { + return Code("return const [];"); + } + + for (final field in fields) { final isOptionalValue = isValue(field.returns!); final statements = []; @@ -205,8 +236,15 @@ Code _serializerBody(Class base, Allocator allocator, SourceNode schemaSource, } Code _deserializerBody(Class base, Allocator allocator, SourceNode schemaSource, - Map typeOverrides) => - Code("""final builder = ${base.name}Builder(); + Map typeOverrides) { + final fields = base.methods + .where((field) => field.type == MethodType.getter && !field.static) + .toList(); + + return switch (fields) { + [] => Code("return ${base.name}();"), + final nonEmptyFieldsList => Code(""" + final builder = ${base.name}Builder(); final iterator = serialized.iterator; while (iterator.moveNext()) { final key = iterator.current as String; @@ -214,25 +252,25 @@ Code _deserializerBody(Class base, Allocator allocator, SourceNode schemaSource, final Object? value = iterator.current; switch (key) { ${_generateFieldDeserializers( - base, - allocator, - schemaSource, - typeOverrides, - )} + nonEmptyFieldsList, + allocator, + schemaSource, + typeOverrides, + )} } } return builder.build(); - """); + """), + }; +} String _generateFieldDeserializers( - Class clazz, + List fields, Allocator allocator, SourceNode schemaSource, Map typeOverrides, ) => - clazz.methods - .where((field) => field.type == MethodType.getter && !field.static) - .map((field) { + fields.map((field) { var type = field.returns!; final isWrappedValue = isValue(type); if (isWrappedValue) { @@ -243,18 +281,12 @@ String _generateFieldDeserializers( final typeDefNode = getTypeDefinitionNode( schemaSource.document, type.symbol.substring(1)); - print(typeDefNode.runtimeType.toString() + - " " + - (typeDefNode?.name.value.toString() ?? "")); - //TODO this feels flaky, find a better way final isBuilder = type.url != null && !isWrappedValue && (typeDefNode is! ScalarTypeDefinitionNode && typeDefNode is! EnumTypeDefinitionNode); - /// TODO check for wireName - var base = """ case '${_getWireName(field)}': var fieldValue = serializers.deserialize( @@ -308,11 +340,24 @@ bool isValue(Reference ref) { } String _getWireName(Method m) { - final annotation = m.annotations.firstWhereOrNull( - (a) => a is InvokeExpression && a.name == "BuiltValueField") - as InvokeExpression?; - if (annotation == null) return m.name!; - return (annotation.namedArguments["wireName"] as LiteralExpression?) - ?.literal ?? - m.name!; + final wireNameExpr = m.annotations + .map((annotation) { + if (annotation + case InvokeExpression( + target: Reference(symbol: "BuiltValueField") + )) { + return annotation.namedArguments["wireName"]; + } + return null; + }) + .whereNotNull() + .firstOrNull; + + if (wireNameExpr is! LiteralExpression) { + return m.name!; + } + // remove quotes from string literal + return wireNameExpr.literal.substring(1, wireNameExpr.literal.length - 1); } + +enum TriStateValueConfig { onAllNullableFields, never } diff --git a/links/gql_exec/lib/src/value.dart b/links/gql_exec/lib/src/value.dart index 30ccd5ad..ddb9f53e 100644 --- a/links/gql_exec/lib/src/value.dart +++ b/links/gql_exec/lib/src/value.dart @@ -1,4 +1,4 @@ -/// A value that may or may not be present. +/// A nullable value that may or may not be present. /// This is used to represent three possible states: /// - The value is absent. It will not be serialized. /// - The value is present and null. It will be serialized as null. @@ -13,6 +13,24 @@ sealed class Value { /// If the value is null, it will be serialized as null. /// If the value is non-null, it will be serialized as the value. const factory Value.present(T value) = PresentValue; + + /// Returns the value if present (no matter if null or non-null), otherwise throws a [StateError]. + T? get requireValue => switch (this) { + PresentValue(:final value) => value, + AbsentValue() => throw StateError("Value is absent"), + }; + + /// return the value if present and non-null, otherwise null. + /// this is useful for cases where you don't care between the value being absent or null. + T? get valueOrNull => switch (this) { + PresentValue(:final value) => value, + AbsentValue() => null, + }; + + bool get isPresent => switch (this) { + PresentValue() => true, + AbsentValue() => false, + }; } class AbsentValue extends Value { From 207951849b3da7667b9ec110e8780fce8565a6fd Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 12 Nov 2023 14:54:03 +0000 Subject: [PATCH 05/10] docs(gql_build): add documentation on tristate_optionals --- codegen/gql_build/README.md | 47 ++++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/codegen/gql_build/README.md b/codegen/gql_build/README.md index 7ce876c6..d402d08e 100644 --- a/codegen/gql_build/README.md +++ b/codegen/gql_build/README.md @@ -22,7 +22,7 @@ A package for Dart code generation from GraphQL source. -Builders in this package let you build your GraphQL requests and view the response in a type-safe way. +Builders in this package let you build your GraphQL requests and view the response in a type-safe way. ## Usage example @@ -39,6 +39,22 @@ Generates a typed view of your data. ### var_builder Creates data classes for any GraphQL variables used in a query or fragment. +#### Configuration + +`tristate_optionals:` [bool\] Whether to wrap nullable fields in a `Value` class in order to distinguish between three cases: +- absent +- null +- non-null value + + +Example: +```yaml + + tristate_optionals: true + +``` + + ### schema_builder Creates data classes from your specified graphql schema. @@ -46,43 +62,42 @@ Creates data classes from your specified graphql schema. `type_overrides`: [Map\] Specify how scalar types should be serialized -Example: + + +Example: ```yaml type_overrides: CustomStringScalar: name: String - CustomField: + CustomField: name: CustomField import: 'package:mypackage/custom_field.dart' ``` -`enum_fallbacks`: \[Map\] Specify fallback values to enum values in order to not break the serializer when +`enum_fallbacks`: \[Map\] Specify fallback values to enum values in order to not break the serializer when new enum values are added to the schema and the client has not updated to the new schema yet. `global_enum_fallbacks`: \[bool\] Add a generated fallback value for each enum value (except for ones that have a custom fallback value specified in the enum_fallbacks map). Defaults to false. -`when_extensions`: [Map\] whether to enable the `when`/`maybeWhen` extension on the generated data classes -from inline fragment spreads with type conditions. -Supported keys are `when` and `maybeWhen`, and the values are booleans indicating whether to enable -generation of the extension method not. - - Example: ```yaml -when_extensions: - when: true # enable the `when` extension method - maybeWhen: true # enable the `maybeWhen` extension method +global_enum_fallbacks: true # add a generated fallback value to all enums +enum_fallbacks: + MyEnumType: OTHER # except for the type 'MyEnumType', use the value 'OTHER' as fallback there ``` +`tristate_optionals`: [bool\] Whether to wrap nullable fields in input types in a `Value` class in order distinguish between three cases: +- absent +- null +- non-null value + Example: ```yaml -global_enum_fallbacks: true # add a generated fallback value to all enums -enum_fallbacks: - MyEnumType: OTHER # except for the type 'MyEnumType', use the value 'OTHER' as fallback there +tristate_optionals: true ``` ### serializer_builder From 5f0f803979e8b4338888745d8769cd06bdeabb8f Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 12 Nov 2023 15:50:48 +0000 Subject: [PATCH 06/10] refactor(gql_code_builder): re-organize code to avoid cyclical deps --- .../alias_var_fragment.var.gql.dart | 4 +- .../__generated__/aliased_hero.var.gql.dart | 2 +- .../fragment_with_scalar_var.var.gql.dart | 4 +- .../hero_with_fragments.var.gql.dart | 7 +- ..._interface_subtyped_fragments.var.gql.dart | 8 +- .../multiple_fragments.var.gql.dart | 7 +- .../__generated__/schema.schema.gql.dart | 11 +- .../hero_for_episode.var.gql.dart | 4 +- .../__generated__/hero_no_vars.var.gql.dart | 3 +- .../review_with_date.var.gql.dart | 2 +- .../create_custom_field.var.gql.dart | 2 +- .../__generated__/create_review.var.gql.dart | 2 +- .../human_with_args.var.gql.dart | 2 +- codegen/gql_build/lib/src/schema_builder.dart | 1 - codegen/gql_build/lib/src/utils/config.dart | 1 - codegen/gql_code_builder/CHANGELOG.md | 6 +- codegen/gql_code_builder/lib/schema.dart | 4 +- codegen/gql_code_builder/lib/src/common.dart | 6 +- .../src/config/tristate_optionals_config.dart | 2 + codegen/gql_code_builder/lib/src/schema.dart | 2 +- .../lib/src/schema/input.dart | 3 +- .../lib/src/tristate_optionals.dart | 274 ++++++++++++++++++ .../lib/src/utils/parse_literal_string.dart | 9 + codegen/gql_code_builder/lib/var.dart | 248 +--------------- codegen/gql_code_builder/pubspec.yaml | 4 +- .../__generated__/serializers.gql.g.dart | 2 +- .../__generated__/all_pokemon.data.gql.dart | 6 + .../__generated__/all_pokemon.data.gql.g.dart | 22 +- .../__generated__/all_pokemon.req.gql.dart | 3 + .../__generated__/all_pokemon.req.gql.g.dart | 8 +- .../__generated__/all_pokemon.var.gql.dart | 2 + .../__generated__/all_pokemon.var.gql.g.dart | 7 +- .../nested_fragment.data.gql.dart | 3 + .../nested_fragment.data.gql.g.dart | 10 +- .../nested_fragment.var.gql.dart | 2 + .../nested_fragment.var.gql.g.dart | 2 +- .../pokemon_card_fragment.data.gql.dart | 3 + .../pokemon_card_fragment.data.gql.g.dart | 14 +- .../pokemon_card_fragment.var.gql.dart | 2 + .../pokemon_card_fragment.var.gql.g.dart | 2 +- .../pokemon_detail.data.gql.dart | 12 + .../pokemon_detail.data.gql.g.dart | 44 ++- .../__generated__/pokemon_detail.req.gql.dart | 3 + .../pokemon_detail.req.gql.g.dart | 8 +- .../__generated__/pokemon_detail.var.gql.dart | 2 + .../pokemon_detail.var.gql.g.dart | 8 +- 46 files changed, 459 insertions(+), 324 deletions(-) create mode 100644 codegen/gql_code_builder/lib/src/config/tristate_optionals_config.dart create mode 100644 codegen/gql_code_builder/lib/src/tristate_optionals.dart create mode 100644 codegen/gql_code_builder/lib/src/utils/parse_literal_string.dart diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.dart index bdad206b..3c5880d7 100644 --- a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.dart @@ -54,7 +54,7 @@ abstract class GPostFragmentVars GPostFragmentVarsSerializer(); } -class GPostsVarsSerializer extends StructuredSerializer { +final class GPostsVarsSerializer extends StructuredSerializer { final String wireName = 'GPostsVars'; final Iterable types = const [GPostsVars, _$GPostsVars]; @@ -94,7 +94,7 @@ class GPostsVarsSerializer extends StructuredSerializer { } } -class GPostFragmentVarsSerializer +final class GPostFragmentVarsSerializer extends StructuredSerializer { final String wireName = 'GPostFragmentVars'; diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.dart index 964f799a..fbcf4377 100644 --- a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.dart @@ -35,7 +35,7 @@ abstract class GAliasedHeroVars GAliasedHeroVarsSerializer(); } -class GAliasedHeroVarsSerializer +final class GAliasedHeroVarsSerializer extends StructuredSerializer { final String wireName = 'GAliasedHeroVars'; diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart index f99413c0..8ab5c60b 100644 --- a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart @@ -66,7 +66,7 @@ abstract class GPostFragmentForUser1Vars GPostFragmentForUser1VarsSerializer(); } -class GPostsWithFixedVariableVarsSerializer +final class GPostsWithFixedVariableVarsSerializer extends StructuredSerializer { final String wireName = 'GPostsWithFixedVariableVars'; @@ -113,7 +113,7 @@ class GPostsWithFixedVariableVarsSerializer } } -class GPostFragmentForUser1VarsSerializer +final class GPostFragmentForUser1VarsSerializer extends StructuredSerializer { final String wireName = 'GPostFragmentForUser1Vars'; diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.dart index d354e80f..eb938ee0 100644 --- a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.dart @@ -85,7 +85,7 @@ abstract class GcomparisonFieldsVars GcomparisonFieldsVarsSerializer(); } -class GHeroWithFragmentsVarsSerializer +final class GHeroWithFragmentsVarsSerializer extends StructuredSerializer { final String wireName = 'GHeroWithFragmentsVars'; @@ -132,7 +132,8 @@ class GHeroWithFragmentsVarsSerializer } } -class GheroDataVarsSerializer extends StructuredSerializer { +final class GheroDataVarsSerializer + extends StructuredSerializer { final String wireName = 'GheroDataVars'; final Iterable types = const [GheroDataVars, _$GheroDataVars]; @@ -154,7 +155,7 @@ class GheroDataVarsSerializer extends StructuredSerializer { } } -class GcomparisonFieldsVarsSerializer +final class GcomparisonFieldsVarsSerializer extends StructuredSerializer { final String wireName = 'GcomparisonFieldsVars'; diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart index 085117ba..ee0fce58 100644 --- a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart @@ -113,7 +113,7 @@ abstract class GdroidFieldsFragmentVars GdroidFieldsFragmentVarsSerializer(); } -class GHeroWithInterfaceSubTypedFragmentsVarsSerializer +final class GHeroWithInterfaceSubTypedFragmentsVarsSerializer extends StructuredSerializer { final String wireName = 'GHeroWithInterfaceSubTypedFragmentsVars'; @@ -157,7 +157,7 @@ class GHeroWithInterfaceSubTypedFragmentsVarsSerializer } } -class GheroFieldsFragmentVarsSerializer +final class GheroFieldsFragmentVarsSerializer extends StructuredSerializer { final String wireName = 'GheroFieldsFragmentVars'; @@ -183,7 +183,7 @@ class GheroFieldsFragmentVarsSerializer } } -class GhumanFieldsFragmentVarsSerializer +final class GhumanFieldsFragmentVarsSerializer extends StructuredSerializer { final String wireName = 'GhumanFieldsFragmentVars'; @@ -209,7 +209,7 @@ class GhumanFieldsFragmentVarsSerializer } } -class GdroidFieldsFragmentVarsSerializer +final class GdroidFieldsFragmentVarsSerializer extends StructuredSerializer { final String wireName = 'GdroidFieldsFragmentVars'; diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.dart index 4e61b86a..b1767084 100644 --- a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.dart @@ -80,7 +80,7 @@ abstract class GheroIdVars implements Built { static Serializer get serializer => GheroIdVarsSerializer(); } -class GHeroWith2FragmentsVarsSerializer +final class GHeroWith2FragmentsVarsSerializer extends StructuredSerializer { final String wireName = 'GHeroWith2FragmentsVars'; @@ -127,7 +127,8 @@ class GHeroWith2FragmentsVarsSerializer } } -class GheroNameVarsSerializer extends StructuredSerializer { +final class GheroNameVarsSerializer + extends StructuredSerializer { final String wireName = 'GheroNameVars'; final Iterable types = const [GheroNameVars, _$GheroNameVars]; @@ -149,7 +150,7 @@ class GheroNameVarsSerializer extends StructuredSerializer { } } -class GheroIdVarsSerializer extends StructuredSerializer { +final class GheroIdVarsSerializer extends StructuredSerializer { final String wireName = 'GheroIdVars'; final Iterable types = const [GheroIdVars, _$GheroIdVars]; diff --git a/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.dart b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.dart index d755beab..a4fe44e2 100644 --- a/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.dart @@ -74,7 +74,7 @@ abstract class GReviewInput static Serializer get serializer => GReviewInputSerializer(); } -class GReviewInputSerializer extends StructuredSerializer { +final class GReviewInputSerializer extends StructuredSerializer { final String wireName = 'GReviewInput'; final Iterable types = const [GReviewInput, _$GReviewInput]; @@ -174,7 +174,7 @@ abstract class GCustomFieldInput GCustomFieldInputSerializer(); } -class GCustomFieldInputSerializer +final class GCustomFieldInputSerializer extends StructuredSerializer { final String wireName = 'GCustomFieldInput'; @@ -250,7 +250,7 @@ abstract class GColorInput implements Built { static Serializer get serializer => GColorInputSerializer(); } -class GColorInputSerializer extends StructuredSerializer { +final class GColorInputSerializer extends StructuredSerializer { final String wireName = 'GColorInput'; final Iterable types = const [GColorInput, _$GColorInput]; @@ -330,7 +330,8 @@ abstract class GPostLikesInput GPostLikesInputSerializer(); } -class GPostLikesInputSerializer extends StructuredSerializer { +final class GPostLikesInputSerializer + extends StructuredSerializer { final String wireName = 'GPostLikesInput'; final Iterable types = const [GPostLikesInput, _$GPostLikesInput]; @@ -394,7 +395,7 @@ abstract class GPostFavoritesInput GPostFavoritesInputSerializer(); } -class GPostFavoritesInputSerializer +final class GPostFavoritesInputSerializer extends StructuredSerializer { final String wireName = 'GPostFavoritesInput'; diff --git a/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.dart b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.dart index 77934652..b02ed542 100644 --- a/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.dart @@ -58,7 +58,7 @@ abstract class GDroidFragmentVars GDroidFragmentVarsSerializer(); } -class GHeroForEpisodeVarsSerializer +final class GHeroForEpisodeVarsSerializer extends StructuredSerializer { final String wireName = 'GHeroForEpisodeVars'; @@ -102,7 +102,7 @@ class GHeroForEpisodeVarsSerializer } } -class GDroidFragmentVarsSerializer +final class GDroidFragmentVarsSerializer extends StructuredSerializer { final String wireName = 'GDroidFragmentVars'; diff --git a/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.var.gql.dart b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.var.gql.dart index 413f8e4e..57b58b74 100644 --- a/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/no_vars/__generated__/hero_no_vars.var.gql.dart @@ -32,7 +32,8 @@ abstract class GHeroNoVarsVars GHeroNoVarsVarsSerializer(); } -class GHeroNoVarsVarsSerializer extends StructuredSerializer { +final class GHeroNoVarsVarsSerializer + extends StructuredSerializer { final String wireName = 'GHeroNoVarsVars'; final Iterable types = const [GHeroNoVarsVars, _$GHeroNoVarsVars]; diff --git a/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.dart b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.dart index bcecfafc..7f0934b0 100644 --- a/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.dart @@ -42,7 +42,7 @@ abstract class GReviewWithDateVars GReviewWithDateVarsSerializer(); } -class GReviewWithDateVarsSerializer +final class GReviewWithDateVarsSerializer extends StructuredSerializer { final String wireName = 'GReviewWithDateVars'; diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.dart index 44f2c7fc..8920ef18 100644 --- a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.dart @@ -36,7 +36,7 @@ abstract class GCreateCustomFieldVars GCreateCustomFieldVarsSerializer(); } -class GCreateCustomFieldVarsSerializer +final class GCreateCustomFieldVarsSerializer extends StructuredSerializer { final String wireName = 'GCreateCustomFieldVars'; diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.dart index 8899db93..507612e0 100644 --- a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.dart @@ -40,7 +40,7 @@ abstract class GCreateReviewVars GCreateReviewVarsSerializer(); } -class GCreateReviewVarsSerializer +final class GCreateReviewVarsSerializer extends StructuredSerializer { final String wireName = 'GCreateReviewVars'; diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.dart index c8edb3ee..83710f19 100644 --- a/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.dart @@ -33,7 +33,7 @@ abstract class GHumanWithArgsVars GHumanWithArgsVarsSerializer(); } -class GHumanWithArgsVarsSerializer +final class GHumanWithArgsVarsSerializer extends StructuredSerializer { final String wireName = 'GHumanWithArgsVars'; diff --git a/codegen/gql_build/lib/src/schema_builder.dart b/codegen/gql_build/lib/src/schema_builder.dart index 50659478..1a8c78a8 100644 --- a/codegen/gql_build/lib/src/schema_builder.dart +++ b/codegen/gql_build/lib/src/schema_builder.dart @@ -4,7 +4,6 @@ import "package:build/build.dart"; import "package:code_builder/code_builder.dart"; import "package:gql_build/src/allocators/gql_allocator.dart"; import "package:gql_code_builder/schema.dart"; -import "package:gql_code_builder/var.dart"; import "package:path/path.dart"; import "./config.dart"; diff --git a/codegen/gql_build/lib/src/utils/config.dart b/codegen/gql_build/lib/src/utils/config.dart index bccbb848..408b5e3a 100644 --- a/codegen/gql_build/lib/src/utils/config.dart +++ b/codegen/gql_build/lib/src/utils/config.dart @@ -1,7 +1,6 @@ import "package:code_builder/code_builder.dart"; import "package:gql_code_builder/data.dart"; import "package:gql_code_builder/schema.dart"; -import "package:gql_code_builder/var.dart"; import "package:yaml/yaml.dart"; Map typeOverrideMap(dynamic typeOverrideConfig) { diff --git a/codegen/gql_code_builder/CHANGELOG.md b/codegen/gql_code_builder/CHANGELOG.md index e824239c..080b1f42 100644 --- a/codegen/gql_code_builder/CHANGELOG.md +++ b/codegen/gql_code_builder/CHANGELOG.md @@ -1,6 +1,10 @@ +## 0.9.9 + +- + ## 0.8.0 -- add `DataClassConfig` option to reuse data classes when a selection set only consists of a single fragment spread +- add experimental `DataClassConfig` option to reuse data classes when a selection set only consists of a single fragment spread ## 0.7.2 diff --git a/codegen/gql_code_builder/lib/schema.dart b/codegen/gql_code_builder/lib/schema.dart index 4b2a9d21..df9464ca 100644 --- a/codegen/gql_code_builder/lib/schema.dart +++ b/codegen/gql_code_builder/lib/schema.dart @@ -2,11 +2,13 @@ import "package:code_builder/code_builder.dart"; import "package:gql/ast.dart"; import "package:gql_code_builder/source.dart"; import "package:gql_code_builder/src/config/enum_fallback_config.dart"; +import "package:gql_code_builder/src/config/tristate_optionals_config.dart"; import "package:gql_code_builder/src/schema.dart"; import "package:gql_code_builder/src/utils/possible_types.dart"; -import "package:gql_code_builder/var.dart"; export "package:gql_code_builder/src/config/enum_fallback_config.dart"; +export "./src/config/tristate_optionals_config.dart"; + Library buildSchemaLibrary(SourceNode schemaSource, String partUrl, Map typeOverrides, EnumFallbackConfig enumFallbackConfig, diff --git a/codegen/gql_code_builder/lib/src/common.dart b/codegen/gql_code_builder/lib/src/common.dart index 8d4be055..2e19f393 100644 --- a/codegen/gql_code_builder/lib/src/common.dart +++ b/codegen/gql_code_builder/lib/src/common.dart @@ -2,7 +2,7 @@ import "package:built_collection/built_collection.dart"; import "package:code_builder/code_builder.dart"; import "package:collection/collection.dart"; import "package:gql/ast.dart"; -import "package:gql_code_builder/var.dart"; +import "package:gql_code_builder/src/config/tristate_optionals_config.dart"; import "../source.dart"; @@ -181,6 +181,9 @@ Method buildGetter({ ); } +/// like [buildGetter] but wraps the return type in a [Value] for nullable types +/// in order to distinguish between `null` and absent values +/// if [useTriStateValueForNullableTypes] is [TriStateValueConfig.onAllNullableFields] Method buildOptionalGetter({ required NameNode nameNode, required TypeNode typeNode, @@ -206,7 +209,6 @@ Method buildOptionalGetter({ useTriStateValueForNullableTypes == TriStateValueConfig.never) { return baseGetter; } - ; final optionalGetter = baseGetter.rebuild((b) => b ..returns = TypeReference((b2) => b2 diff --git a/codegen/gql_code_builder/lib/src/config/tristate_optionals_config.dart b/codegen/gql_code_builder/lib/src/config/tristate_optionals_config.dart new file mode 100644 index 00000000..90a9f78f --- /dev/null +++ b/codegen/gql_code_builder/lib/src/config/tristate_optionals_config.dart @@ -0,0 +1,2 @@ + +enum TriStateValueConfig { onAllNullableFields, never } diff --git a/codegen/gql_code_builder/lib/src/schema.dart b/codegen/gql_code_builder/lib/src/schema.dart index e486fbed..f0b2bcdc 100644 --- a/codegen/gql_code_builder/lib/src/schema.dart +++ b/codegen/gql_code_builder/lib/src/schema.dart @@ -1,6 +1,6 @@ import "package:code_builder/code_builder.dart"; import "package:gql/ast.dart"; -import "package:gql_code_builder/var.dart"; +import "package:gql_code_builder/src/tristate_optionals.dart"; import "./schema/enum.dart"; import "./schema/input.dart"; diff --git a/codegen/gql_code_builder/lib/src/schema/input.dart b/codegen/gql_code_builder/lib/src/schema/input.dart index 0b4cdea1..1a73f099 100644 --- a/codegen/gql_code_builder/lib/src/schema/input.dart +++ b/codegen/gql_code_builder/lib/src/schema/input.dart @@ -1,6 +1,7 @@ import "package:code_builder/code_builder.dart"; import "package:gql/ast.dart"; -import "package:gql_code_builder/var.dart"; +import "package:gql_code_builder/src/config/tristate_optionals_config.dart"; +import "package:gql_code_builder/src/tristate_optionals.dart"; import "../../source.dart"; import "../built_class.dart"; diff --git a/codegen/gql_code_builder/lib/src/tristate_optionals.dart b/codegen/gql_code_builder/lib/src/tristate_optionals.dart new file mode 100644 index 00000000..4f9aff4a --- /dev/null +++ b/codegen/gql_code_builder/lib/src/tristate_optionals.dart @@ -0,0 +1,274 @@ +import "package:code_builder/code_builder.dart"; +import "package:collection/collection.dart"; +import "package:gql/ast.dart"; +import "package:gql_code_builder/source.dart"; +import "package:gql_code_builder/src/common.dart"; +import "package:gql_code_builder/src/utils/parse_literal_string.dart"; + +/// add a static custom serializer to the generated class which +/// is aware of the `Value` type and can serialize it to json +/// in order to distinguish between `null`, and absent values +/// use the corresponding nullAwareJsonSerializerClass() method +/// to generate the serializer class which is referenced here +Method nullAwareJsonSerializerField(Node op, String className) => + Method((b) => b + ..annotations.add(CodeExpression( + Code("BuiltValueSerializer(custom: true, serializeNulls: true)"))) + ..static = true + ..type = MethodType.getter + ..lambda = true + ..returns = TypeReference((b2) => b2 + ..symbol = "Serializer" + ..url = "package:built_value/serializer.dart" + ..types.add(refer(className))) + ..name = "serializer" + ..body = Code("${className}Serializer()")); + + +/// builds a custom serializer for the generated class which +/// is aware of the `Value` type and can serialize it to json +/// in order to distinguish between `null`, and absent values +/// use the corresponding nullAwareJsonSerializerField() method +/// to add the serializer to the generated class +Class nullAwareJsonSerializerClass( + Class base, + Allocator allocator, + SourceNode schemaSource, + Map typeOverrides, + ) => + Class((b) => b + ..name = "${base.name}Serializer" + ..modifier = ClassModifier.final$ + ..extend = TypeReference((b) => b + ..symbol = "StructuredSerializer" + ..url = "package:built_value/serializer.dart" + ..types.add(refer(base.name))) + ..fields.addAll([ + Field( + (b) => b + ..name = "wireName" + ..modifier = FieldModifier.final$ + ..type = refer("String") + ..assignment = (literalString(base.name)).code, + ), + Field((b) => b + ..name = "types" + ..modifier = FieldModifier.final$ + ..type = TypeReference((b2) => b2..symbol = "Iterable") + ..assignment = Code("const [${base.name}, _\$${base.name}]")) + ]) + ..methods.addAll([ + Method((b) => b + ..name = "serialize" + ..returns = refer("Iterable") + ..requiredParameters.add(Parameter((b) => b + ..name = "serializers" + ..type = + refer("Serializers", "package:built_value/serializer.dart"))) + ..requiredParameters.add(Parameter((b) => b + ..name = "object" + ..type = refer(base.name))) + ..optionalParameters.add(Parameter((b) => b + ..name = "specifiedType" + ..named = true + ..type = refer("FullType", "package:built_value/serializer.dart") + ..defaultTo = Code("FullType.unspecified"))) + ..body = + _serializerBody(base, allocator, schemaSource, typeOverrides)), + Method((b) => b + ..name = "deserialize" + ..returns = refer(base.name) + ..requiredParameters.add(Parameter((b) => b + ..name = "serializers" + ..type = + refer("Serializers", "package:built_value/serializer.dart"))) + ..requiredParameters.add(Parameter((b) => b + ..name = "serialized" + ..type = refer("Iterable"))) + ..optionalParameters.add(Parameter((b) => b + ..name = "specifiedType" + ..named = true + ..type = refer("FullType", "package:built_value/serializer.dart") + ..defaultTo = Code("FullType.unspecified"))) + ..body = + _deserializerBody(base, allocator, schemaSource, typeOverrides)), + ])); + + + +Code _serializerBody(Class base, Allocator allocator, SourceNode schemaSource, + Map typeOverrides) { + final vars = []; + + final fields = base.methods + .where((field) => field.type == MethodType.getter && !field.static) + .toList(); + + if (fields.isEmpty) { + return Code("return const [];"); + } + + for (final field in fields) { + final isOptionalValue = isValue(field.returns!); + final statements = []; + + if (isOptionalValue) { + final realType = + (field.returns as TypeReference).types.first as TypeReference; + + final _valueVarName = "_\$${field.name}value"; + + statements.add(Code("final $_valueVarName = object.${field.name};")); + statements.add(Code( + "if ($_valueVarName case ${allocator.allocate(refer("PresentValue", 'package:gql_exec/value.dart'))}(value: final _\$value) ) {")); + statements.add(Code("result.add('${_getWireName(field)}');")); + statements.add(Code( + "result.add(serializers.serialize(_\$value, specifiedType: const ${_generateFullType(realType, allocator)}));")); + statements.add(Code("}")); + } else { + statements.add(Code("result.add('${_getWireName(field)}');")); + statements.add(Code( + "result.add(serializers.serialize(object.${field.name}, specifiedType: const ${_generateFullType(field.returns as TypeReference, allocator)}));")); + } + vars.add(Block.of(statements)); + } + + final body = Block.of([ + Code("final result = [];"), + ...vars, + Code("return result;"), + ]); + + return body; +} + +Code _deserializerBody(Class base, Allocator allocator, SourceNode schemaSource, + Map typeOverrides) { + final fields = base.methods + .where((field) => field.type == MethodType.getter && !field.static) + .toList(); + + return switch (fields) { + [] => Code("return ${base.name}();"), + final nonEmptyFieldsList => Code(""" + final builder = ${base.name}Builder(); + final iterator = serialized.iterator; + while (iterator.moveNext()) { + final key = iterator.current as String; + iterator.moveNext(); + final Object? value = iterator.current; + switch (key) { + ${_generateFieldDeserializers( + nonEmptyFieldsList, + allocator, + schemaSource, + typeOverrides, + )} + } + } + return builder.build(); + """), + }; +} + + +String _generateFieldDeserializers( + List fields, + Allocator allocator, + SourceNode schemaSource, + Map typeOverrides, + ) => + fields.map((field) { + var type = field.returns!; + final isWrappedValue = isValue(type); + if (isWrappedValue) { + type = (type as TypeReference).types.first; + } + final fullType = _generateFullType(type as TypeReference, allocator); + + /// remove the leading `G` from the type name + /// TODO refactor this + final originalSymbolName = type.symbol.substring(1); + + final typeDefNode = getTypeDefinitionNode( + schemaSource.document,originalSymbolName ); + + //TODO this feels flaky, find a better way + final isBuilder = type.url != null && + !isWrappedValue && + (typeDefNode is! ScalarTypeDefinitionNode && + typeDefNode is! EnumTypeDefinitionNode); + + var base = """ +case '${_getWireName(field)}': + var fieldValue = serializers.deserialize( + value, specifiedType: const $fullType) as ${_generateTypeCast(type, allocator)};"""; + + if (isBuilder) { + base += """ + builder.${field.name}.replace(fieldValue); + """; + } else { + base += """ + builder.${field.name} = ${isWrappedValue ? "${allocator.allocate(_presentValueTypeRef)}(fieldValue)" : "fieldValue"}; + """; + } + + return base + + """ +break; +"""; + }).join(); + + +String _getWireName(Method m) { + final wireNameExpr = m.annotations + .map((annotation) { + if (annotation + case InvokeExpression( + target: Reference(symbol: "BuiltValueField") + )) { + return annotation.namedArguments["wireName"]; + } + return null; + }) + .whereNotNull() + .firstOrNull; + + if (wireNameExpr is! LiteralExpression) { + return m.name!; + } + // remove quotes from string literal + return parseLiteralString(wireNameExpr); +} + +bool isValue(Reference ref) { + if (ref is! TypeReference) return false; + + return ref.symbol == _valueTypeRef.symbol && ref.url == _valueTypeRef.url; +} + +Code _generateFullType(TypeReference ref, Allocator allocator) { + if (ref.types.isEmpty) { + return Code("FullType(${allocator.allocate(ref)})"); + } else { + return Code( + "FullType(${allocator.allocate(ref)}, [${ref.types.map((t) => _generateFullType(t as TypeReference, allocator)).join(",")}])"); + } +} + +String _generateTypeCast(TypeReference ref, Allocator allocator) { + if (ref.types.isEmpty) { + return allocator.allocate(ref); + } else { + return "${allocator.allocate(ref)}<${ref.types.map((t) => _generateTypeCast(t as TypeReference, allocator)).join(",")}>"; + } +} + +final _valueTypeRef = TypeReference((b) => b + ..symbol = "Value" + ..url = "package:gql_exec/value.dart"); + +final _presentValueTypeRef = TypeReference((b) => b + ..symbol = "PresentValue" + ..url = "package:gql_exec/value.dart"); diff --git a/codegen/gql_code_builder/lib/src/utils/parse_literal_string.dart b/codegen/gql_code_builder/lib/src/utils/parse_literal_string.dart new file mode 100644 index 00000000..9add57b0 --- /dev/null +++ b/codegen/gql_code_builder/lib/src/utils/parse_literal_string.dart @@ -0,0 +1,9 @@ +import "package:code_builder/code_builder.dart"; + + +/// gets a string literal from a LiteralExpression +/// and returns it as a Dart String without the quotes +String parseLiteralString(LiteralExpression stringLiteral) => + + stringLiteral.literal.substring(1, stringLiteral.literal.length - 1); + diff --git a/codegen/gql_code_builder/lib/var.dart b/codegen/gql_code_builder/lib/var.dart index 1e099155..05885cd7 100644 --- a/codegen/gql_code_builder/lib/var.dart +++ b/codegen/gql_code_builder/lib/var.dart @@ -1,12 +1,15 @@ import "package:code_builder/code_builder.dart"; -import "package:collection/collection.dart"; import "package:gql/ast.dart"; +import "package:gql_code_builder/src/config/tristate_optionals_config.dart"; +import "package:gql_code_builder/src/tristate_optionals.dart"; import "./source.dart"; import "./src/built_class.dart"; import "./src/common.dart"; import "./src/frag_vars.dart"; +export "./src/config/tristate_optionals_config.dart"; + Library buildVarLibrary( SourceNode docSource, SourceNode schemaSource, @@ -112,252 +115,9 @@ Map _varClassValueInitializers( .constInstance(const []) }; -Method nullAwareJsonSerializerField(Node op, String className) => - Method((b) => b - ..annotations.add(CodeExpression( - Code("BuiltValueSerializer(custom: true, serializeNulls: true)"))) - ..static = true - ..type = MethodType.getter - ..lambda = true - ..returns = TypeReference((b2) => b2 - ..symbol = "Serializer" - ..url = "package:built_value/serializer.dart" - ..types.add(refer(className))) - ..name = "serializer" - ..body = Code("${className}Serializer()")); - -Class nullAwareJsonSerializerClass( - Class base, - Allocator allocator, - SourceNode schemaSource, - Map typeOverrides, -) => - Class((b) => b - ..name = "${base.name}Serializer" - ..extend = TypeReference((b) => b - ..symbol = "StructuredSerializer" - ..url = "package:built_value/serializer.dart" - ..types.add(refer(base.name))) - ..fields.addAll([ - Field( - (b) => b - ..name = "wireName" - ..modifier = FieldModifier.final$ - ..type = refer("String") - ..assignment = (literalString(base.name)).code, - ), - Field((b) => b - ..name = "types" - ..modifier = FieldModifier.final$ - ..type = TypeReference((b2) => b2..symbol = "Iterable") - ..assignment = Code("const [${base.name}, _\$${base.name}]")) - ]) - ..methods.addAll([ - Method((b) => b - ..name = "serialize" - ..returns = refer("Iterable") - ..requiredParameters.add(Parameter((b) => b - ..name = "serializers" - ..type = - refer("Serializers", "package:built_value/serializer.dart"))) - ..requiredParameters.add(Parameter((b) => b - ..name = "object" - ..type = refer(base.name))) - ..optionalParameters.add(Parameter((b) => b - ..name = "specifiedType" - ..named = true - ..type = refer("FullType", "package:built_value/serializer.dart") - ..defaultTo = Code("FullType.unspecified"))) - ..body = - _serializerBody(base, allocator, schemaSource, typeOverrides)), - Method((b) => b - ..name = "deserialize" - ..returns = refer(base.name) - ..requiredParameters.add(Parameter((b) => b - ..name = "serializers" - ..type = - refer("Serializers", "package:built_value/serializer.dart"))) - ..requiredParameters.add(Parameter((b) => b - ..name = "serialized" - ..type = refer("Iterable"))) - ..optionalParameters.add(Parameter((b) => b - ..name = "specifiedType" - ..named = true - ..type = refer("FullType", "package:built_value/serializer.dart") - ..defaultTo = Code("FullType.unspecified"))) - ..body = - _deserializerBody(base, allocator, schemaSource, typeOverrides)), - ])); - -Code _serializerBody(Class base, Allocator allocator, SourceNode schemaSource, - Map typeOverrides) { - final vars = []; - - final fields = base.methods - .where((field) => field.type == MethodType.getter && !field.static) - .toList(); - - if (fields.isEmpty) { - return Code("return const [];"); - } - - for (final field in fields) { - final isOptionalValue = isValue(field.returns!); - final statements = []; - if (isOptionalValue) { - final realType = - (field.returns as TypeReference).types.first as TypeReference; - final _valueVarName = "_\$${field.name}value"; - - statements.add(Code("final $_valueVarName = object.${field.name};")); - statements.add(Code( - "if ($_valueVarName case ${allocator.allocate(refer("PresentValue", 'package:gql_exec/value.dart'))}(value: final _\$value) ) {")); - statements.add(Code("result.add('${_getWireName(field)}');")); - statements.add(Code( - "result.add(serializers.serialize(_\$value, specifiedType: const ${_generateFullType(realType, allocator)}));")); - statements.add(Code("}")); - } else { - statements.add(Code("result.add('${_getWireName(field)}');")); - statements.add(Code( - "result.add(serializers.serialize(object.${field.name}, specifiedType: const ${_generateFullType(field.returns as TypeReference, allocator)}));")); - } - vars.add(Block.of(statements)); - } - - final body = Block.of([ - Code("final result = [];"), - ...vars, - Code("return result;"), - ]); - - return body; -} - -Code _deserializerBody(Class base, Allocator allocator, SourceNode schemaSource, - Map typeOverrides) { - final fields = base.methods - .where((field) => field.type == MethodType.getter && !field.static) - .toList(); - - return switch (fields) { - [] => Code("return ${base.name}();"), - final nonEmptyFieldsList => Code(""" - final builder = ${base.name}Builder(); - final iterator = serialized.iterator; - while (iterator.moveNext()) { - final key = iterator.current as String; - iterator.moveNext(); - final Object? value = iterator.current; - switch (key) { - ${_generateFieldDeserializers( - nonEmptyFieldsList, - allocator, - schemaSource, - typeOverrides, - )} - } - } - return builder.build(); - """), - }; -} -String _generateFieldDeserializers( - List fields, - Allocator allocator, - SourceNode schemaSource, - Map typeOverrides, -) => - fields.map((field) { - var type = field.returns!; - final isWrappedValue = isValue(type); - if (isWrappedValue) { - type = (type as TypeReference).types.first; - } - final fullType = _generateFullType(type as TypeReference, allocator); - final typeDefNode = getTypeDefinitionNode( - schemaSource.document, type.symbol.substring(1)); - //TODO this feels flaky, find a better way - final isBuilder = type.url != null && - !isWrappedValue && - (typeDefNode is! ScalarTypeDefinitionNode && - typeDefNode is! EnumTypeDefinitionNode); - - var base = """ -case '${_getWireName(field)}': - var fieldValue = serializers.deserialize( - value, specifiedType: const $fullType) as ${_generateTypeCast(type, allocator)};"""; - - if (isBuilder) { - base += """ - builder.${field.name}.replace(fieldValue); - """; - } else { - base += """ - builder.${field.name} = ${isWrappedValue ? "${allocator.allocate(_presentValueTypeRef)}(fieldValue)" : "fieldValue"}; - """; - } - - return base + - """ -break; -"""; - }).join(); - -Code _generateFullType(TypeReference ref, Allocator allocator) { - if (ref.types.isEmpty) { - return Code("FullType(${allocator.allocate(ref)})"); - } else { - return Code( - "FullType(${allocator.allocate(ref)}, [${ref.types.map((t) => _generateFullType(t as TypeReference, allocator)).join(",")}])"); - } -} - -String _generateTypeCast(TypeReference ref, Allocator allocator) { - if (ref.types.isEmpty) { - return allocator.allocate(ref); - } else { - return "${allocator.allocate(ref)}<${ref.types.map((t) => _generateTypeCast(t as TypeReference, allocator)).join(",")}>"; - } -} - -final _valueTypeRef = TypeReference((b) => b - ..symbol = "Value" - ..url = "package:gql_exec/value.dart"); - -final _presentValueTypeRef = TypeReference((b) => b - ..symbol = "PresentValue" - ..url = "package:gql_exec/value.dart"); - -bool isValue(Reference ref) { - if (ref is! TypeReference) return false; - - return ref.symbol == _valueTypeRef.symbol && ref.url == _valueTypeRef.url; -} - -String _getWireName(Method m) { - final wireNameExpr = m.annotations - .map((annotation) { - if (annotation - case InvokeExpression( - target: Reference(symbol: "BuiltValueField") - )) { - return annotation.namedArguments["wireName"]; - } - return null; - }) - .whereNotNull() - .firstOrNull; - - if (wireNameExpr is! LiteralExpression) { - return m.name!; - } - // remove quotes from string literal - return wireNameExpr.literal.substring(1, wireNameExpr.literal.length - 1); -} -enum TriStateValueConfig { onAllNullableFields, never } diff --git a/codegen/gql_code_builder/pubspec.yaml b/codegen/gql_code_builder/pubspec.yaml index 70568994..91eb3376 100644 --- a/codegen/gql_code_builder/pubspec.yaml +++ b/codegen/gql_code_builder/pubspec.yaml @@ -1,5 +1,5 @@ name: gql_code_builder -version: 0.8.0 +version: 0.9.0 description: Dart code builders taking *.graphql documents and SDL to build useful classes. repository: https://github.com/gql-dart/gql environment: @@ -8,7 +8,7 @@ dependencies: analyzer: '>=4.6.0 <7.0.0' built_collection: ^5.0.0 built_value: ^8.0.6 - code_builder: ^4.3.0 + code_builder: ^4.7.0 collection: ^1.15.0 gql: ^1.0.0 gql_exec: ^1.0.0 diff --git a/examples/gql_example_flutter/lib/graphql/__generated__/serializers.gql.g.dart b/examples/gql_example_flutter/lib/graphql/__generated__/serializers.gql.g.dart index e9dcb996..40913fee 100644 --- a/examples/gql_example_flutter/lib/graphql/__generated__/serializers.gql.g.dart +++ b/examples/gql_example_flutter/lib/graphql/__generated__/serializers.gql.g.dart @@ -27,4 +27,4 @@ Serializers _$serializers = (new Serializers().toBuilder() () => new ListBuilder())) .build(); -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.data.gql.dart b/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.data.gql.dart index 81b912eb..802d5b42 100644 --- a/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.data.gql.dart +++ b/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.data.gql.dart @@ -21,15 +21,18 @@ abstract class GAllPokemonData static void _initializeBuilder(GAllPokemonDataBuilder b) => b..G__typename = 'Query'; + @BuiltValueField(wireName: '__typename') String get G__typename; BuiltList? get pokemons; static Serializer get serializer => _$gAllPokemonDataSerializer; + Map toJson() => (_i1.serializers.serializeWith( GAllPokemonData.serializer, this, ) as Map); + static GAllPokemonData? fromJson(Map json) => _i1.serializers.deserializeWith( GAllPokemonData.serializer, @@ -49,6 +52,7 @@ abstract class GAllPokemonData_pokemons static void _initializeBuilder(GAllPokemonData_pokemonsBuilder b) => b..G__typename = 'Pokemon'; + @override @BuiltValueField(wireName: '__typename') String get G__typename; @@ -62,11 +66,13 @@ abstract class GAllPokemonData_pokemons String? get name; static Serializer get serializer => _$gAllPokemonDataPokemonsSerializer; + @override Map toJson() => (_i1.serializers.serializeWith( GAllPokemonData_pokemons.serializer, this, ) as Map); + static GAllPokemonData_pokemons? fromJson(Map json) => _i1.serializers.deserializeWith( GAllPokemonData_pokemons.serializer, diff --git a/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.data.gql.g.dart b/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.data.gql.g.dart index 2edd02db..81151e2a 100644 --- a/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.data.gql.g.dart +++ b/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.data.gql.g.dart @@ -183,7 +183,11 @@ class _$GAllPokemonData extends GAllPokemonData { @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), pokemons.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, pokemons.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -312,12 +316,14 @@ class _$GAllPokemonData_pokemons extends GAllPokemonData_pokemons { @override int get hashCode { - return $jf($jc( - $jc( - $jc($jc($jc(0, G__typename.hashCode), maxHP.hashCode), - image.hashCode), - id.hashCode), - name.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, maxHP.hashCode); + _$hash = $jc(_$hash, image.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -403,4 +409,4 @@ class GAllPokemonData_pokemonsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.req.gql.dart b/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.req.gql.dart index 35c1f56c..72b29d9e 100644 --- a/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.req.gql.dart +++ b/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.req.gql.dart @@ -24,13 +24,16 @@ abstract class GAllPokemon implements Built { document: _i2.document, operationName: 'AllPokemon', ); + _i3.GAllPokemonVars get vars; _i1.Operation get operation; static Serializer get serializer => _$gAllPokemonSerializer; + Map toJson() => (_i4.serializers.serializeWith( GAllPokemon.serializer, this, ) as Map); + static GAllPokemon? fromJson(Map json) => _i4.serializers.deserializeWith( GAllPokemon.serializer, diff --git a/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.req.gql.g.dart b/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.req.gql.g.dart index 8d34c46e..5ead8702 100644 --- a/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.req.gql.g.dart +++ b/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.req.gql.g.dart @@ -88,7 +88,11 @@ class _$GAllPokemon extends GAllPokemon { @override int get hashCode { - return $jf($jc($jc(0, vars.hashCode), operation.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -164,4 +168,4 @@ class GAllPokemonBuilder implements Builder { } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.var.gql.dart b/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.var.gql.dart index 6275b218..ad061ff9 100644 --- a/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.var.gql.dart +++ b/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.var.gql.dart @@ -19,10 +19,12 @@ abstract class GAllPokemonVars int get first; static Serializer get serializer => _$gAllPokemonVarsSerializer; + Map toJson() => (_i1.serializers.serializeWith( GAllPokemonVars.serializer, this, ) as Map); + static GAllPokemonVars? fromJson(Map json) => _i1.serializers.deserializeWith( GAllPokemonVars.serializer, diff --git a/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.var.gql.g.dart b/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.var.gql.g.dart index 553c17bf..a345e591 100644 --- a/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.var.gql.g.dart +++ b/examples/gql_example_flutter/lib/src/all_pokemon/graphql/__generated__/all_pokemon.var.gql.g.dart @@ -77,7 +77,10 @@ class _$GAllPokemonVars extends GAllPokemonVars { @override int get hashCode { - return $jf($jc(0, first.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, first.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -131,4 +134,4 @@ class GAllPokemonVarsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.data.gql.dart b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.data.gql.dart index 91bc5f92..d1dbff1f 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.data.gql.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.data.gql.dart @@ -27,6 +27,7 @@ abstract class GNestedFragmentData static void _initializeBuilder(GNestedFragmentDataBuilder b) => b..G__typename = 'Pokemon'; + @override @BuiltValueField(wireName: '__typename') String get G__typename; @@ -36,11 +37,13 @@ abstract class GNestedFragmentData String? get name; static Serializer get serializer => _$gNestedFragmentDataSerializer; + @override Map toJson() => (_i1.serializers.serializeWith( GNestedFragmentData.serializer, this, ) as Map); + static GNestedFragmentData? fromJson(Map json) => _i1.serializers.deserializeWith( GNestedFragmentData.serializer, diff --git a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.data.gql.g.dart b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.data.gql.g.dart index bb0c73ef..ae8e51da 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.data.gql.g.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.data.gql.g.dart @@ -112,8 +112,12 @@ class _$GNestedFragmentData extends GNestedFragmentData { @override int get hashCode { - return $jf( - $jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -184,4 +188,4 @@ class GNestedFragmentDataBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.var.gql.dart b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.var.gql.dart index faa64886..a280311f 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.var.gql.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.var.gql.dart @@ -18,10 +18,12 @@ abstract class GNestedFragmentVars static Serializer get serializer => _$gNestedFragmentVarsSerializer; + Map toJson() => (_i1.serializers.serializeWith( GNestedFragmentVars.serializer, this, ) as Map); + static GNestedFragmentVars? fromJson(Map json) => _i1.serializers.deserializeWith( GNestedFragmentVars.serializer, diff --git a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.var.gql.g.dart b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.var.gql.g.dart index 122ecff7..35db0661 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.var.gql.g.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/nested_fragment.var.gql.g.dart @@ -94,4 +94,4 @@ class GNestedFragmentVarsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.data.gql.dart b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.data.gql.dart index e49cfb3a..126d5358 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.data.gql.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.data.gql.dart @@ -36,6 +36,7 @@ abstract class GPokemonCardData static void _initializeBuilder(GPokemonCardDataBuilder b) => b..G__typename = 'Pokemon'; + @override @BuiltValueField(wireName: '__typename') String get G__typename; @@ -49,11 +50,13 @@ abstract class GPokemonCardData String? get image; static Serializer get serializer => _$gPokemonCardDataSerializer; + @override Map toJson() => (_i2.serializers.serializeWith( GPokemonCardData.serializer, this, ) as Map); + static GPokemonCardData? fromJson(Map json) => _i2.serializers.deserializeWith( GPokemonCardData.serializer, diff --git a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.data.gql.g.dart b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.data.gql.g.dart index d397962b..bd2eafd4 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.data.gql.g.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.data.gql.g.dart @@ -138,10 +138,14 @@ class _$GPokemonCardData extends GPokemonCardData { @override int get hashCode { - return $jf($jc( - $jc($jc($jc($jc(0, G__typename.hashCode), id.hashCode), name.hashCode), - maxHP.hashCode), - image.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, maxHP.hashCode); + _$hash = $jc(_$hash, image.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -226,4 +230,4 @@ class GPokemonCardDataBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.var.gql.dart b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.var.gql.dart index b0547df5..8128d3ce 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.var.gql.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.var.gql.dart @@ -18,10 +18,12 @@ abstract class GPokemonCardVars static Serializer get serializer => _$gPokemonCardVarsSerializer; + Map toJson() => (_i1.serializers.serializeWith( GPokemonCardVars.serializer, this, ) as Map); + static GPokemonCardVars? fromJson(Map json) => _i1.serializers.deserializeWith( GPokemonCardVars.serializer, diff --git a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.var.gql.g.dart b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.var.gql.g.dart index 609a7259..4512fb2b 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.var.gql.g.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_card/graphql/__generated__/pokemon_card_fragment.var.gql.g.dart @@ -89,4 +89,4 @@ class GPokemonCardVarsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.data.gql.dart b/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.data.gql.dart index e70991c4..afe60c22 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.data.gql.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.data.gql.dart @@ -20,15 +20,18 @@ abstract class GPokemonDetailData static void _initializeBuilder(GPokemonDetailDataBuilder b) => b..G__typename = 'Query'; + @BuiltValueField(wireName: '__typename') String get G__typename; GPokemonDetailData_pokemon? get pokemon; static Serializer get serializer => _$gPokemonDetailDataSerializer; + Map toJson() => (_i1.serializers.serializeWith( GPokemonDetailData.serializer, this, ) as Map); + static GPokemonDetailData? fromJson(Map json) => _i1.serializers.deserializeWith( GPokemonDetailData.serializer, @@ -48,6 +51,7 @@ abstract class GPokemonDetailData_pokemon static void _initializeBuilder(GPokemonDetailData_pokemonBuilder b) => b..G__typename = 'Pokemon'; + @override @BuiltValueField(wireName: '__typename') String get G__typename; @@ -63,11 +67,13 @@ abstract class GPokemonDetailData_pokemon GPokemonDetailData_pokemon_height? get height; static Serializer get serializer => _$gPokemonDetailDataPokemonSerializer; + @override Map toJson() => (_i1.serializers.serializeWith( GPokemonDetailData_pokemon.serializer, this, ) as Map); + static GPokemonDetailData_pokemon? fromJson(Map json) => _i1.serializers.deserializeWith( GPokemonDetailData_pokemon.serializer, @@ -87,16 +93,19 @@ abstract class GPokemonDetailData_pokemon_weight static void _initializeBuilder(GPokemonDetailData_pokemon_weightBuilder b) => b..G__typename = 'PokemonDimension'; + @BuiltValueField(wireName: '__typename') String get G__typename; String? get minimum; String? get maximum; static Serializer get serializer => _$gPokemonDetailDataPokemonWeightSerializer; + Map toJson() => (_i1.serializers.serializeWith( GPokemonDetailData_pokemon_weight.serializer, this, ) as Map); + static GPokemonDetailData_pokemon_weight? fromJson( Map json) => _i1.serializers.deserializeWith( @@ -117,16 +126,19 @@ abstract class GPokemonDetailData_pokemon_height static void _initializeBuilder(GPokemonDetailData_pokemon_heightBuilder b) => b..G__typename = 'PokemonDimension'; + @BuiltValueField(wireName: '__typename') String get G__typename; String? get minimum; String? get maximum; static Serializer get serializer => _$gPokemonDetailDataPokemonHeightSerializer; + Map toJson() => (_i1.serializers.serializeWith( GPokemonDetailData_pokemon_height.serializer, this, ) as Map); + static GPokemonDetailData_pokemon_height? fromJson( Map json) => _i1.serializers.deserializeWith( diff --git a/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.data.gql.g.dart b/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.data.gql.g.dart index ce28ea7a..0c62df3a 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.data.gql.g.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.data.gql.g.dart @@ -353,7 +353,11 @@ class _$GPokemonDetailData extends GPokemonDetailData { @override int get hashCode { - return $jf($jc($jc(0, G__typename.hashCode), pokemon.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, pokemon.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -490,16 +494,16 @@ class _$GPokemonDetailData_pokemon extends GPokemonDetailData_pokemon { @override int get hashCode { - return $jf($jc( - $jc( - $jc( - $jc( - $jc($jc($jc(0, G__typename.hashCode), maxHP.hashCode), - image.hashCode), - id.hashCode), - name.hashCode), - weight.hashCode), - height.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, maxHP.hashCode); + _$hash = $jc(_$hash, image.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, weight.hashCode); + _$hash = $jc(_$hash, height.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -659,8 +663,12 @@ class _$GPokemonDetailData_pokemon_weight @override int get hashCode { - return $jf($jc( - $jc($jc(0, G__typename.hashCode), minimum.hashCode), maximum.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, minimum.hashCode); + _$hash = $jc(_$hash, maximum.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -774,8 +782,12 @@ class _$GPokemonDetailData_pokemon_height @override int get hashCode { - return $jf($jc( - $jc($jc(0, G__typename.hashCode), minimum.hashCode), maximum.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, minimum.hashCode); + _$hash = $jc(_$hash, maximum.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -848,4 +860,4 @@ class GPokemonDetailData_pokemon_heightBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.req.gql.dart b/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.req.gql.dart index 1145e567..e98fc233 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.req.gql.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.req.gql.dart @@ -26,14 +26,17 @@ abstract class GPokemonDetail document: _i2.document, operationName: 'PokemonDetail', ); + _i3.GPokemonDetailVars get vars; _i1.Operation get operation; static Serializer get serializer => _$gPokemonDetailSerializer; + Map toJson() => (_i4.serializers.serializeWith( GPokemonDetail.serializer, this, ) as Map); + static GPokemonDetail? fromJson(Map json) => _i4.serializers.deserializeWith( GPokemonDetail.serializer, diff --git a/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.req.gql.g.dart b/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.req.gql.g.dart index 98bf80da..f5129efa 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.req.gql.g.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.req.gql.g.dart @@ -93,7 +93,11 @@ class _$GPokemonDetail extends GPokemonDetail { @override int get hashCode { - return $jf($jc($jc(0, vars.hashCode), operation.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, vars.hashCode); + _$hash = $jc(_$hash, operation.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -170,4 +174,4 @@ class GPokemonDetailBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.var.gql.dart b/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.var.gql.dart index e5fa7962..f49b9547 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.var.gql.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.var.gql.dart @@ -20,10 +20,12 @@ abstract class GPokemonDetailVars String? get name; static Serializer get serializer => _$gPokemonDetailVarsSerializer; + Map toJson() => (_i1.serializers.serializeWith( GPokemonDetailVars.serializer, this, ) as Map); + static GPokemonDetailVars? fromJson(Map json) => _i1.serializers.deserializeWith( GPokemonDetailVars.serializer, diff --git a/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.var.gql.g.dart b/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.var.gql.g.dart index 6c9028ad..5e9021a7 100644 --- a/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.var.gql.g.dart +++ b/examples/gql_example_flutter/lib/src/pokemon_detail/graphql/__generated__/pokemon_detail.var.gql.g.dart @@ -95,7 +95,11 @@ class _$GPokemonDetailVars extends GPokemonDetailVars { @override int get hashCode { - return $jf($jc($jc(0, id.hashCode), name.hashCode)); + var _$hash = 0; + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, name.hashCode); + _$hash = $jf(_$hash); + return _$hash; } @override @@ -152,4 +156,4 @@ class GPokemonDetailVarsBuilder } } -// ignore_for_file: always_put_control_body_on_new_line,always_specify_types,annotate_overrides,avoid_annotating_with_dynamic,avoid_as,avoid_catches_without_on_clauses,avoid_returning_this,deprecated_member_use_from_same_package,lines_longer_than_80_chars,no_leading_underscores_for_local_identifiers,omit_local_variable_types,prefer_expression_function_bodies,sort_constructors_first,test_types_in_equals,unnecessary_const,unnecessary_new,unnecessary_lambdas +// ignore_for_file: deprecated_member_use_from_same_package,type=lint From 845dae1a316665c194d5b8f5468042479516302b Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 12 Nov 2023 15:57:54 +0000 Subject: [PATCH 07/10] fmt --- codegen/gql_code_builder/lib/schema.dart | 1 - .../src/config/tristate_optionals_config.dart | 1 - .../lib/src/tristate_optionals.dart | 98 ++++++++++--------- .../lib/src/utils/parse_literal_string.dart | 5 +- codegen/gql_code_builder/lib/var.dart | 10 +- 5 files changed, 55 insertions(+), 60 deletions(-) diff --git a/codegen/gql_code_builder/lib/schema.dart b/codegen/gql_code_builder/lib/schema.dart index df9464ca..b4724675 100644 --- a/codegen/gql_code_builder/lib/schema.dart +++ b/codegen/gql_code_builder/lib/schema.dart @@ -9,7 +9,6 @@ import "package:gql_code_builder/src/utils/possible_types.dart"; export "package:gql_code_builder/src/config/enum_fallback_config.dart"; export "./src/config/tristate_optionals_config.dart"; - Library buildSchemaLibrary(SourceNode schemaSource, String partUrl, Map typeOverrides, EnumFallbackConfig enumFallbackConfig, {bool generatePossibleTypesMap = false, diff --git a/codegen/gql_code_builder/lib/src/config/tristate_optionals_config.dart b/codegen/gql_code_builder/lib/src/config/tristate_optionals_config.dart index 90a9f78f..2f544fe0 100644 --- a/codegen/gql_code_builder/lib/src/config/tristate_optionals_config.dart +++ b/codegen/gql_code_builder/lib/src/config/tristate_optionals_config.dart @@ -1,2 +1 @@ - enum TriStateValueConfig { onAllNullableFields, never } diff --git a/codegen/gql_code_builder/lib/src/tristate_optionals.dart b/codegen/gql_code_builder/lib/src/tristate_optionals.dart index 4f9aff4a..c8c435a2 100644 --- a/codegen/gql_code_builder/lib/src/tristate_optionals.dart +++ b/codegen/gql_code_builder/lib/src/tristate_optionals.dart @@ -24,18 +24,17 @@ Method nullAwareJsonSerializerField(Node op, String className) => ..name = "serializer" ..body = Code("${className}Serializer()")); - /// builds a custom serializer for the generated class which /// is aware of the `Value` type and can serialize it to json /// in order to distinguish between `null`, and absent values /// use the corresponding nullAwareJsonSerializerField() method /// to add the serializer to the generated class Class nullAwareJsonSerializerClass( - Class base, - Allocator allocator, - SourceNode schemaSource, - Map typeOverrides, - ) => + Class base, + Allocator allocator, + SourceNode schemaSource, + Map typeOverrides, +) => Class((b) => b ..name = "${base.name}Serializer" ..modifier = ClassModifier.final$ @@ -45,7 +44,7 @@ Class nullAwareJsonSerializerClass( ..types.add(refer(base.name))) ..fields.addAll([ Field( - (b) => b + (b) => b ..name = "wireName" ..modifier = FieldModifier.final$ ..type = refer("String") @@ -64,7 +63,7 @@ Class nullAwareJsonSerializerClass( ..requiredParameters.add(Parameter((b) => b ..name = "serializers" ..type = - refer("Serializers", "package:built_value/serializer.dart"))) + refer("Serializers", "package:built_value/serializer.dart"))) ..requiredParameters.add(Parameter((b) => b ..name = "object" ..type = refer(base.name))) @@ -74,14 +73,14 @@ Class nullAwareJsonSerializerClass( ..type = refer("FullType", "package:built_value/serializer.dart") ..defaultTo = Code("FullType.unspecified"))) ..body = - _serializerBody(base, allocator, schemaSource, typeOverrides)), + _serializerBody(base, allocator, schemaSource, typeOverrides)), Method((b) => b ..name = "deserialize" ..returns = refer(base.name) ..requiredParameters.add(Parameter((b) => b ..name = "serializers" ..type = - refer("Serializers", "package:built_value/serializer.dart"))) + refer("Serializers", "package:built_value/serializer.dart"))) ..requiredParameters.add(Parameter((b) => b ..name = "serialized" ..type = refer("Iterable"))) @@ -91,11 +90,9 @@ Class nullAwareJsonSerializerClass( ..type = refer("FullType", "package:built_value/serializer.dart") ..defaultTo = Code("FullType.unspecified"))) ..body = - _deserializerBody(base, allocator, schemaSource, typeOverrides)), + _deserializerBody(base, allocator, schemaSource, typeOverrides)), ])); - - Code _serializerBody(Class base, Allocator allocator, SourceNode schemaSource, Map typeOverrides) { final vars = []; @@ -114,7 +111,7 @@ Code _serializerBody(Class base, Allocator allocator, SourceNode schemaSource, if (isOptionalValue) { final realType = - (field.returns as TypeReference).types.first as TypeReference; + (field.returns as TypeReference).types.first as TypeReference; final _valueVarName = "_\$${field.name}value"; @@ -159,11 +156,11 @@ Code _deserializerBody(Class base, Allocator allocator, SourceNode schemaSource, final Object? value = iterator.current; switch (key) { ${_generateFieldDeserializers( - nonEmptyFieldsList, - allocator, - schemaSource, - typeOverrides, - )} + nonEmptyFieldsList, + allocator, + schemaSource, + typeOverrides, + )} } } return builder.build(); @@ -171,13 +168,12 @@ Code _deserializerBody(Class base, Allocator allocator, SourceNode schemaSource, }; } - String _generateFieldDeserializers( - List fields, - Allocator allocator, - SourceNode schemaSource, - Map typeOverrides, - ) => + List fields, + Allocator allocator, + SourceNode schemaSource, + Map typeOverrides, +) => fields.map((field) { var type = field.returns!; final isWrappedValue = isValue(type); @@ -190,8 +186,8 @@ String _generateFieldDeserializers( /// TODO refactor this final originalSymbolName = type.symbol.substring(1); - final typeDefNode = getTypeDefinitionNode( - schemaSource.document,originalSymbolName ); + final typeDefNode = + getTypeDefinitionNode(schemaSource.document, originalSymbolName); //TODO this feels flaky, find a better way final isBuilder = type.url != null && @@ -210,7 +206,7 @@ case '${_getWireName(field)}': """; } else { base += """ - builder.${field.name} = ${isWrappedValue ? "${allocator.allocate(_presentValueTypeRef)}(fieldValue)" : "fieldValue"}; + builder.${field.name} = ${isWrappedValue ? "${allocator.allocate(presentValueTypeRef)}(fieldValue)" : "fieldValue"}; """; } @@ -220,18 +216,17 @@ break; """; }).join(); - String _getWireName(Method m) { final wireNameExpr = m.annotations .map((annotation) { - if (annotation - case InvokeExpression( - target: Reference(symbol: "BuiltValueField") - )) { - return annotation.namedArguments["wireName"]; - } - return null; - }) + if (annotation + case InvokeExpression( + target: Reference(symbol: "BuiltValueField") + )) { + return annotation.namedArguments["wireName"]; + } + return null; + }) .whereNotNull() .firstOrNull; @@ -245,7 +240,7 @@ String _getWireName(Method m) { bool isValue(Reference ref) { if (ref is! TypeReference) return false; - return ref.symbol == _valueTypeRef.symbol && ref.url == _valueTypeRef.url; + return ref.symbol == valueTypeRef.symbol && ref.url == valueTypeRef.url; } Code _generateFullType(TypeReference ref, Allocator allocator) { @@ -265,10 +260,23 @@ String _generateTypeCast(TypeReference ref, Allocator allocator) { } } -final _valueTypeRef = TypeReference((b) => b - ..symbol = "Value" - ..url = "package:gql_exec/value.dart"); - -final _presentValueTypeRef = TypeReference((b) => b - ..symbol = "PresentValue" - ..url = "package:gql_exec/value.dart"); +const valueTypeSymbol = "Value"; +const valueTypeUrl = "package:gql_exec/value.dart"; + +final valueTypeRef = TypeReference( + (b) => b + ..symbol = valueTypeSymbol + ..url = valueTypeUrl, +); + +final presentValueTypeRef = TypeReference( + (b) => b + ..symbol = "PresentValue" + ..url = valueTypeUrl, +); + +final absentValueTypeRef = TypeReference( + (b) => b + ..symbol = "AbsentValue" + ..url = valueTypeUrl, +); diff --git a/codegen/gql_code_builder/lib/src/utils/parse_literal_string.dart b/codegen/gql_code_builder/lib/src/utils/parse_literal_string.dart index 9add57b0..cb7bf1a8 100644 --- a/codegen/gql_code_builder/lib/src/utils/parse_literal_string.dart +++ b/codegen/gql_code_builder/lib/src/utils/parse_literal_string.dart @@ -1,9 +1,6 @@ import "package:code_builder/code_builder.dart"; - /// gets a string literal from a LiteralExpression /// and returns it as a Dart String without the quotes String parseLiteralString(LiteralExpression stringLiteral) => - - stringLiteral.literal.substring(1, stringLiteral.literal.length - 1); - + stringLiteral.literal.substring(1, stringLiteral.literal.length - 1); diff --git a/codegen/gql_code_builder/lib/var.dart b/codegen/gql_code_builder/lib/var.dart index 05885cd7..cdb93902 100644 --- a/codegen/gql_code_builder/lib/var.dart +++ b/codegen/gql_code_builder/lib/var.dart @@ -111,13 +111,5 @@ Map _varClassValueInitializers( for (final node in op.variableDefinitions.where((element) => !element.type.isNonNull)) identifier(node.variable.name.value): - refer("AbsentValue", "package:gql_exec/value.dart") - .constInstance(const []) + absentValueTypeRef.constInstance(const []) }; - - - - - - - From 32e6c4a79ca09daa12da5ee363ffea35add72a05 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 12 Nov 2023 17:00:21 +0000 Subject: [PATCH 08/10] refactor: somewhat extract the logic for the value class implementation --- .../alias_var_fragment.var.gql.dart | 8 ++-- .../__generated__/aliased_hero.var.gql.dart | 4 +- .../fragment_with_scalar_var.var.gql.dart | 4 +- .../hero_with_fragments.var.gql.dart | 8 ++-- ..._interface_subtyped_fragments.var.gql.dart | 4 +- .../multiple_fragments.var.gql.dart | 4 +- .../__generated__/schema.schema.gql.dart | 44 +++++++++--------- .../hero_for_episode.var.gql.dart | 4 +- .../review_with_date.var.gql.dart | 12 ++--- .../create_custom_field.var.gql.dart | 4 +- .../__generated__/create_review.var.gql.dart | 8 ++-- .../human_with_args.var.gql.dart | 4 +- .../lib/src/tristate_optionals.dart | 46 ++++++++++++------- codegen/gql_code_builder/lib/var.dart | 3 +- 14 files changed, 85 insertions(+), 72 deletions(-) diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.dart index 3c5880d7..719150a6 100644 --- a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/alias_var_fragment.var.gql.dart @@ -84,9 +84,9 @@ final class GPostsVarsSerializer extends StructuredSerializer { final Object? value = iterator.current; switch (key) { case 'userId': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(String)) as String; - builder.userId = fieldValue; + builder.userId = _$fieldValue; break; } } @@ -125,9 +125,9 @@ final class GPostFragmentVarsSerializer final Object? value = iterator.current; switch (key) { case 'userId': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(String)) as String; - builder.userId = fieldValue; + builder.userId = _$fieldValue; break; } } diff --git a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.dart b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.dart index fbcf4377..8622fa1a 100644 --- a/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/aliases/__generated__/aliased_hero.var.gql.dart @@ -66,9 +66,9 @@ final class GAliasedHeroVarsSerializer final Object? value = iterator.current; switch (key) { case 'ep': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; - builder.ep = fieldValue; + builder.ep = _$fieldValue; break; } } diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart index 8ab5c60b..15d07fff 100644 --- a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/fragment_with_scalar_var.var.gql.dart @@ -103,9 +103,9 @@ final class GPostsWithFixedVariableVarsSerializer final Object? value = iterator.current; switch (key) { case 'filter': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(_i2.GJson)) as _i2.GJson; - builder.filter = _i1.PresentValue(fieldValue); + builder.filter = _i1.PresentValue(_$fieldValue); break; } } diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.dart index eb938ee0..b780f928 100644 --- a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_fragments.var.gql.dart @@ -122,9 +122,9 @@ final class GHeroWithFragmentsVarsSerializer final Object? value = iterator.current; switch (key) { case 'first': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(int)) as int; - builder.first = _i1.PresentValue(fieldValue); + builder.first = _i1.PresentValue(_$fieldValue); break; } } @@ -189,9 +189,9 @@ final class GcomparisonFieldsVarsSerializer final Object? value = iterator.current; switch (key) { case 'first': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(int)) as int; - builder.first = fieldValue; + builder.first = _$fieldValue; break; } } diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart index ee0fce58..b83eb2c6 100644 --- a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.var.gql.dart @@ -147,9 +147,9 @@ final class GHeroWithInterfaceSubTypedFragmentsVarsSerializer final Object? value = iterator.current; switch (key) { case 'episode': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; - builder.episode = fieldValue; + builder.episode = _$fieldValue; break; } } diff --git a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.dart index b1767084..dfcecb9d 100644 --- a/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/multiple_fragments.var.gql.dart @@ -117,9 +117,9 @@ final class GHeroWith2FragmentsVarsSerializer final Object? value = iterator.current; switch (key) { case 'first': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(int)) as int; - builder.first = _i1.PresentValue(fieldValue); + builder.first = _i1.PresentValue(_$fieldValue); break; } } diff --git a/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.dart b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.dart index a4fe44e2..3e7ba076 100644 --- a/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/graphql/__generated__/schema.schema.gql.dart @@ -122,26 +122,26 @@ final class GReviewInputSerializer extends StructuredSerializer { final Object? value = iterator.current; switch (key) { case 'stars': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(int)) as int; - builder.stars = fieldValue; + builder.stars = _$fieldValue; break; case 'commentary': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(String)) as String; - builder.commentary = _i1.PresentValue(fieldValue); + builder.commentary = _i1.PresentValue(_$fieldValue); break; case 'favorite_color': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(GColorInput)) as GColorInput; - builder.favorite_color = _i1.PresentValue(fieldValue); + builder.favorite_color = _i1.PresentValue(_$fieldValue); break; case 'seenOn': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(BuiltList, [FullType(DateTime)])) as BuiltList; - builder.seenOn = _i1.PresentValue(fieldValue); + builder.seenOn = _i1.PresentValue(_$fieldValue); break; } } @@ -211,15 +211,15 @@ final class GCustomFieldInputSerializer final Object? value = iterator.current; switch (key) { case 'id': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(String)) as String; - builder.id = fieldValue; + builder.id = _$fieldValue; break; case 'customField': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(_i2.CustomField)) as _i2.CustomField; - builder.customField = _i1.PresentValue(fieldValue); + builder.customField = _i1.PresentValue(_$fieldValue); break; } } @@ -286,19 +286,19 @@ final class GColorInputSerializer extends StructuredSerializer { final Object? value = iterator.current; switch (key) { case 'red': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(int)) as int; - builder.red = fieldValue; + builder.red = _$fieldValue; break; case 'green': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(int)) as int; - builder.green = fieldValue; + builder.green = _$fieldValue; break; case 'blue': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(int)) as int; - builder.blue = fieldValue; + builder.blue = _$fieldValue; break; } } @@ -361,9 +361,9 @@ final class GPostLikesInputSerializer final Object? value = iterator.current; switch (key) { case 'id': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(String)) as String; - builder.id = fieldValue; + builder.id = _$fieldValue; break; } } @@ -429,9 +429,9 @@ final class GPostFavoritesInputSerializer final Object? value = iterator.current; switch (key) { case 'id': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(String)) as String; - builder.id = fieldValue; + builder.id = _$fieldValue; break; } } diff --git a/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.dart b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.dart index b02ed542..4f793ed6 100644 --- a/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/interfaces/__generated__/hero_for_episode.var.gql.dart @@ -92,9 +92,9 @@ final class GHeroForEpisodeVarsSerializer final Object? value = iterator.current; switch (key) { case 'ep': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(_i1.GEpisode)) as _i1.GEpisode; - builder.ep = fieldValue; + builder.ep = _$fieldValue; break; } } diff --git a/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.dart b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.dart index 7f0934b0..fdc46beb 100644 --- a/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/scalars/__generated__/review_with_date.var.gql.dart @@ -88,20 +88,20 @@ final class GReviewWithDateVarsSerializer final Object? value = iterator.current; switch (key) { case 'episode': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(_i2.GEpisode)) as _i2.GEpisode; - builder.episode = _i1.PresentValue(fieldValue); + builder.episode = _i1.PresentValue(_$fieldValue); break; case 'review': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(_i2.GReviewInput)) as _i2.GReviewInput; - builder.review.replace(fieldValue); + builder.review.replace(_$fieldValue); break; case 'createdAt': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(DateTime)) as DateTime; - builder.createdAt = _i1.PresentValue(fieldValue); + builder.createdAt = _i1.PresentValue(_$fieldValue); break; } } diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.dart index 8920ef18..31341818 100644 --- a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_custom_field.var.gql.dart @@ -70,10 +70,10 @@ final class GCreateCustomFieldVarsSerializer final Object? value = iterator.current; switch (key) { case 'input': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(_i1.GCustomFieldInput)) as _i1.GCustomFieldInput; - builder.input.replace(fieldValue); + builder.input.replace(_$fieldValue); break; } } diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.dart index 507612e0..79844439 100644 --- a/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/create_review.var.gql.dart @@ -77,15 +77,15 @@ final class GCreateReviewVarsSerializer final Object? value = iterator.current; switch (key) { case 'episode': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(_i2.GEpisode)) as _i2.GEpisode; - builder.episode = _i1.PresentValue(fieldValue); + builder.episode = _i1.PresentValue(_$fieldValue); break; case 'review': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(_i2.GReviewInput)) as _i2.GReviewInput; - builder.review.replace(fieldValue); + builder.review.replace(_$fieldValue); break; } } diff --git a/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.dart b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.dart index 83710f19..bc1ca5a3 100644 --- a/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.dart +++ b/codegen/end_to_end_test_tristate/lib/variables/__generated__/human_with_args.var.gql.dart @@ -64,9 +64,9 @@ final class GHumanWithArgsVarsSerializer final Object? value = iterator.current; switch (key) { case 'id': - var fieldValue = serializers.deserialize(value, + var _$fieldValue = serializers.deserialize(value, specifiedType: const FullType(String)) as String; - builder.id = fieldValue; + builder.id = _$fieldValue; break; } } diff --git a/codegen/gql_code_builder/lib/src/tristate_optionals.dart b/codegen/gql_code_builder/lib/src/tristate_optionals.dart index c8c435a2..9febd6dd 100644 --- a/codegen/gql_code_builder/lib/src/tristate_optionals.dart +++ b/codegen/gql_code_builder/lib/src/tristate_optionals.dart @@ -106,7 +106,7 @@ Code _serializerBody(Class base, Allocator allocator, SourceNode schemaSource, } for (final field in fields) { - final isOptionalValue = isValue(field.returns!); + final isOptionalValue = _isValue(field.returns!); final statements = []; if (isOptionalValue) { @@ -117,7 +117,7 @@ Code _serializerBody(Class base, Allocator allocator, SourceNode schemaSource, statements.add(Code("final $_valueVarName = object.${field.name};")); statements.add(Code( - "if ($_valueVarName case ${allocator.allocate(refer("PresentValue", 'package:gql_exec/value.dart'))}(value: final _\$value) ) {")); + "if ($_valueVarName case ${allocator.allocate(presentValueTypeRef)}(value: final _\$value) ) {")); statements.add(Code("result.add('${_getWireName(field)}');")); statements.add(Code( "result.add(serializers.serialize(_\$value, specifiedType: const ${_generateFullType(realType, allocator)}));")); @@ -176,7 +176,7 @@ String _generateFieldDeserializers( ) => fields.map((field) { var type = field.returns!; - final isWrappedValue = isValue(type); + final isWrappedValue = _isValue(type); if (isWrappedValue) { type = (type as TypeReference).types.first; } @@ -195,18 +195,22 @@ String _generateFieldDeserializers( (typeDefNode is! ScalarTypeDefinitionNode && typeDefNode is! EnumTypeDefinitionNode); + const fieldNameVariableName = "_\$fieldValue"; + + final fieldNameExpr = CodeExpression(Code(fieldNameVariableName)); + var base = """ case '${_getWireName(field)}': - var fieldValue = serializers.deserialize( + var ${fieldNameVariableName} = serializers.deserialize( value, specifiedType: const $fullType) as ${_generateTypeCast(type, allocator)};"""; if (isBuilder) { base += """ - builder.${field.name}.replace(fieldValue); + builder.${field.name}.replace($fieldNameVariableName); """; } else { base += """ - builder.${field.name} = ${isWrappedValue ? "${allocator.allocate(presentValueTypeRef)}(fieldValue)" : "fieldValue"}; + builder.${field.name} = ${isWrappedValue ? newPresentValueConstructorInvocation(fieldNameExpr, allocator) : fieldNameVariableName}; """; } @@ -237,12 +241,6 @@ String _getWireName(Method m) { return parseLiteralString(wireNameExpr); } -bool isValue(Reference ref) { - if (ref is! TypeReference) return false; - - return ref.symbol == valueTypeRef.symbol && ref.url == valueTypeRef.url; -} - Code _generateFullType(TypeReference ref, Allocator allocator) { if (ref.types.isEmpty) { return Code("FullType(${allocator.allocate(ref)})"); @@ -269,14 +267,30 @@ final valueTypeRef = TypeReference( ..url = valueTypeUrl, ); -final presentValueTypeRef = TypeReference( +final absentValueTypeRef = TypeReference( (b) => b - ..symbol = "PresentValue" + ..symbol = "AbsentValue" ..url = valueTypeUrl, ); -final absentValueTypeRef = TypeReference( +final presentValueTypeRef = TypeReference( (b) => b - ..symbol = "AbsentValue" + ..symbol = "PresentValue" ..url = valueTypeUrl, ); + +Expression absentValueConstructorInvocation() => + absentValueTypeRef.constInstance(const []); + +String newPresentValueConstructorInvocation( + Expression value, Allocator allocator) { + final prefixedRef = allocator.allocate(presentValueTypeRef); + + return "$prefixedRef(${value.code})"; +} + +bool _isValue(Reference ref) { + if (ref is! TypeReference) return false; + + return ref.symbol == valueTypeRef.symbol && ref.url == valueTypeRef.url; +} diff --git a/codegen/gql_code_builder/lib/var.dart b/codegen/gql_code_builder/lib/var.dart index cdb93902..5c3e32c7 100644 --- a/codegen/gql_code_builder/lib/var.dart +++ b/codegen/gql_code_builder/lib/var.dart @@ -110,6 +110,5 @@ Map _varClassValueInitializers( { for (final node in op.variableDefinitions.where((element) => !element.type.isNonNull)) - identifier(node.variable.name.value): - absentValueTypeRef.constInstance(const []) + identifier(node.variable.name.value): absentValueConstructorInvocation() }; From 3e0c067000d97415d3d61c4bc4a7c16e0de4f2c0 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 12 Nov 2023 17:04:10 +0000 Subject: [PATCH 09/10] fix: add url to builtvaluefield ref check --- codegen/gql_code_builder/lib/src/tristate_optionals.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/codegen/gql_code_builder/lib/src/tristate_optionals.dart b/codegen/gql_code_builder/lib/src/tristate_optionals.dart index 9febd6dd..592093ca 100644 --- a/codegen/gql_code_builder/lib/src/tristate_optionals.dart +++ b/codegen/gql_code_builder/lib/src/tristate_optionals.dart @@ -225,7 +225,10 @@ String _getWireName(Method m) { .map((annotation) { if (annotation case InvokeExpression( - target: Reference(symbol: "BuiltValueField") + target: Reference( + symbol: "BuiltValueField", + url: "package:built_value/built_value.dart", + ) )) { return annotation.namedArguments["wireName"]; } From 08ebd227bc51bbe7c831e010488cf42067a15907 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 12 Nov 2023 17:14:50 +0000 Subject: [PATCH 10/10] bump versions, update CHANGELOG --- codegen/gql_build/CHANGELOG.md | 9 ++++++++- codegen/gql_build/pubspec.yaml | 2 +- codegen/gql_code_builder/CHANGELOG.md | 9 +++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/codegen/gql_build/CHANGELOG.md b/codegen/gql_build/CHANGELOG.md index 3ba778a0..7c738c7c 100644 --- a/codegen/gql_build/CHANGELOG.md +++ b/codegen/gql_build/CHANGELOG.md @@ -1,6 +1,13 @@ +# 0.10.0 + +- add `tristate_optionals` option to `schema_builder` and `var_builder` in order to wrap nullable fields in input types in a `Value` class in order distinguish between three cases: + - absent + - null + - non-null value + # 0.9.0 -- add `reuse_fragments` option to builder in order to reuse data classes of selection sets that only include a single inline fragment spread +- add experimental `reuse_fragments` option to builder in order to reuse data classes of selection sets that only include a single inline fragment spread # 0.8.0 diff --git a/codegen/gql_build/pubspec.yaml b/codegen/gql_build/pubspec.yaml index 932059ad..d034d65a 100644 --- a/codegen/gql_build/pubspec.yaml +++ b/codegen/gql_build/pubspec.yaml @@ -1,5 +1,5 @@ name: gql_build -version: 0.9.0 +version: 0.10.0 description: Useful builders for your GraphQL SDL and documents. Based on package:gql_code_builder and package:build repository: https://github.com/gql-dart/gql environment: diff --git a/codegen/gql_code_builder/CHANGELOG.md b/codegen/gql_code_builder/CHANGELOG.md index 080b1f42..e58356ea 100644 --- a/codegen/gql_code_builder/CHANGELOG.md +++ b/codegen/gql_code_builder/CHANGELOG.md @@ -1,6 +1,11 @@ -## 0.9.9 +## 0.9.0 + +- add TriStateValueConfig option in order to wrap nullable fields in input types in a `Value` class in order distinguish between three cases: + - absent + - null + - non-null value + in serialization -- ## 0.8.0