From 2d9878392898f2fd7805244ffb4cc67b74479f54 Mon Sep 17 00:00:00 2001 From: Christian Budde Christensen Date: Wed, 12 May 2021 07:25:06 +0100 Subject: [PATCH] feat: Expand test --- .../inline_fragments_on_fragments.dart | 150 +++++++++++++++++- 1 file changed, 147 insertions(+), 3 deletions(-) diff --git a/test/query_generator/fragments/inline_fragments_on_fragments.dart b/test/query_generator/fragments/inline_fragments_on_fragments.dart index a8a4a273..326fe542 100644 --- a/test/query_generator/fragments/inline_fragments_on_fragments.dart +++ b/test/query_generator/fragments/inline_fragments_on_fragments.dart @@ -9,9 +9,25 @@ void main() { 'Interface fragments', () async => testGenerator( query: r''' + fragment InterfaceFragment2 on InterfaceA { + interface { + s + } + + ...on ImplementationA { + b + } + ...on ImplementationB { + i2 + } + } fragment InterfaceFragment on InterfaceA { s i + interface { + ...InterfaceFragment2 + } + ...on ImplementationA { b } @@ -46,6 +62,7 @@ void main() { interface InterfaceA { s: String i: Int + interface: InterfaceA } union UnionA = ImplementationA | ImplementationB @@ -75,6 +92,56 @@ final LibraryDefinition libraryDefinition = name: QueryName(name: r'SomeQuery$_Query'), operationName: r'some_query', classes: [ + ClassDefinition( + name: ClassName(name: r'InterfaceFragment2Mixin$_InterfaceA'), + properties: [ + ClassProperty( + type: TypeName(name: r'String'), + name: ClassPropertyName(name: r's'), + isResolveType: false) + ], + factoryPossibilities: {}, + typeNameField: ClassPropertyName(name: r'__typename'), + isInput: false), + ClassDefinition( + name: ClassName(name: r'InterfaceFragment2Mixin$_ImplementationA'), + properties: [ + ClassProperty( + type: TypeName(name: r'bool'), + name: ClassPropertyName(name: r'b'), + isResolveType: false) + ], + mixins: [FragmentName(name: r'InterfaceFragment2Mixin')], + factoryPossibilities: {}, + typeNameField: ClassPropertyName(name: r'__typename'), + isInput: false), + ClassDefinition( + name: ClassName(name: r'InterfaceFragment2Mixin$_ImplementationB'), + properties: [ + ClassProperty( + type: TypeName(name: r'int'), + name: ClassPropertyName(name: r'i2'), + isResolveType: false) + ], + mixins: [FragmentName(name: r'InterfaceFragment2Mixin')], + factoryPossibilities: {}, + typeNameField: ClassPropertyName(name: r'__typename'), + isInput: false), + FragmentClassDefinition( + name: FragmentName(name: r'InterfaceFragment2Mixin'), + properties: [ + ClassProperty( + type: TypeName(name: r'InterfaceFragment2Mixin$_InterfaceA'), + name: ClassPropertyName(name: r'interface'), + annotations: [r'''JsonKey(name: 'interface')'''], + isResolveType: false) + ]), + ClassDefinition( + name: ClassName(name: r'InterfaceFragmentMixin$_InterfaceA'), + mixins: [FragmentName(name: r'InterfaceFragment2Mixin')], + factoryPossibilities: {}, + typeNameField: ClassPropertyName(name: r'__typename'), + isInput: false), ClassDefinition( name: ClassName(name: r'InterfaceFragmentMixin$_ImplementationA'), properties: [ @@ -109,6 +176,11 @@ final LibraryDefinition libraryDefinition = ClassProperty( type: TypeName(name: r'int'), name: ClassPropertyName(name: r'i'), + isResolveType: false), + ClassProperty( + type: TypeName(name: r'InterfaceFragmentMixin$_InterfaceA'), + name: ClassPropertyName(name: r'interface'), + annotations: [r'''JsonKey(name: 'interface')'''], isResolveType: false) ]), ClassDefinition( @@ -178,12 +250,84 @@ import 'package:equatable/equatable.dart'; import 'package:gql/ast.dart'; part 'query.graphql.g.dart'; +mixin InterfaceFragment2Mixin { + @JsonKey(name: 'interface') + InterfaceFragment2Mixin$InterfaceA? kw$interface; +} mixin InterfaceFragmentMixin { String? s; int? i; + @JsonKey(name: 'interface') + InterfaceFragmentMixin$InterfaceA? kw$interface; } mixin UnionFragmentMixin {} +@JsonSerializable(explicitToJson: true) +class InterfaceFragment2Mixin$InterfaceA extends JsonSerializable + with EquatableMixin { + InterfaceFragment2Mixin$InterfaceA(); + + factory InterfaceFragment2Mixin$InterfaceA.fromJson( + Map json) => + _$InterfaceFragment2Mixin$InterfaceAFromJson(json); + + String? s; + + @override + List get props => [s]; + Map toJson() => + _$InterfaceFragment2Mixin$InterfaceAToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class InterfaceFragment2Mixin$ImplementationA extends JsonSerializable + with EquatableMixin, InterfaceFragment2Mixin { + InterfaceFragment2Mixin$ImplementationA(); + + factory InterfaceFragment2Mixin$ImplementationA.fromJson( + Map json) => + _$InterfaceFragment2Mixin$ImplementationAFromJson(json); + + bool? b; + + @override + List get props => [kw$interface, b]; + Map toJson() => + _$InterfaceFragment2Mixin$ImplementationAToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class InterfaceFragment2Mixin$ImplementationB extends JsonSerializable + with EquatableMixin, InterfaceFragment2Mixin { + InterfaceFragment2Mixin$ImplementationB(); + + factory InterfaceFragment2Mixin$ImplementationB.fromJson( + Map json) => + _$InterfaceFragment2Mixin$ImplementationBFromJson(json); + + int? i2; + + @override + List get props => [kw$interface, i2]; + Map toJson() => + _$InterfaceFragment2Mixin$ImplementationBToJson(this); +} + +@JsonSerializable(explicitToJson: true) +class InterfaceFragmentMixin$InterfaceA extends JsonSerializable + with EquatableMixin, InterfaceFragment2Mixin { + InterfaceFragmentMixin$InterfaceA(); + + factory InterfaceFragmentMixin$InterfaceA.fromJson( + Map json) => + _$InterfaceFragmentMixin$InterfaceAFromJson(json); + + @override + List get props => [kw$interface]; + Map toJson() => + _$InterfaceFragmentMixin$InterfaceAToJson(this); +} + @JsonSerializable(explicitToJson: true) class InterfaceFragmentMixin$ImplementationA extends JsonSerializable with EquatableMixin, InterfaceFragmentMixin { @@ -196,7 +340,7 @@ class InterfaceFragmentMixin$ImplementationA extends JsonSerializable bool? b; @override - List get props => [s, i, b]; + List get props => [s, i, kw$interface, b]; Map toJson() => _$InterfaceFragmentMixin$ImplementationAToJson(this); } @@ -213,7 +357,7 @@ class InterfaceFragmentMixin$ImplementationB extends JsonSerializable int? i2; @override - List get props => [s, i, i2]; + List get props => [s, i, kw$interface, i2]; Map toJson() => _$InterfaceFragmentMixin$ImplementationBToJson(this); } @@ -261,7 +405,7 @@ class SomeQuery$Query$InterfaceA extends JsonSerializable _$SomeQuery$Query$InterfaceAFromJson(json); @override - List get props => [s, i]; + List get props => [s, i, kw$interface]; Map toJson() => _$SomeQuery$Query$InterfaceAToJson(this); }