From 0161ac1da3b48ad23f15b589231046e62ee7056a Mon Sep 17 00:00:00 2001 From: Christian Budde Christensen Date: Sun, 5 Jul 2026 21:16:28 +0100 Subject: [PATCH] feat: Support fragments on fragments on types on types --- packages/graphql_codegen/example/pubspec.lock | 16 +- packages/graphql_codegen/example/pubspec.yaml | 2 +- .../lib/src/config/config.dart | 3 - .../src/transform/transforming_visitor.dart | 2 + .../lib/src/visitor/context_visitor.dart | 42 +- packages/graphql_codegen/pubspec.lock | 10 +- packages/graphql_codegen/pubspec.yaml | 2 +- .../test/assets/issue_415/schema.graphql | 29 + .../test/assets/issue_415/schema.graphql.dart | 938 ++++++++++++++++++ pubspec.lock | 50 +- 10 files changed, 1028 insertions(+), 66 deletions(-) create mode 100644 packages/graphql_codegen/test/assets/issue_415/schema.graphql create mode 100644 packages/graphql_codegen/test/assets/issue_415/schema.graphql.dart diff --git a/packages/graphql_codegen/example/pubspec.lock b/packages/graphql_codegen/example/pubspec.lock index 29f18d10..3bde318a 100644 --- a/packages/graphql_codegen/example/pubspec.lock +++ b/packages/graphql_codegen/example/pubspec.lock @@ -93,10 +93,10 @@ packages: dependency: transitive description: name: characters - sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 + sha256: faf38497bda5ead2a8c7615f4f7939df04333478bf32e4173fcb06d428b5716b url: "https://pub.dev" source: hosted - version: "1.4.0" + version: "1.4.1" checked_yaml: dependency: transitive description: @@ -337,7 +337,7 @@ packages: path: ".." relative: true source: path - version: "3.0.0" + version: "3.0.1" graphql_flutter: dependency: "direct main" description: @@ -430,18 +430,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec + sha256: "9c337007e82b1889149c82ed242ed1cb24a66044e30979c44912381e9be4c48b" url: "https://pub.dev" source: hosted - version: "0.11.1" + version: "0.13.0" meta: dependency: transitive description: name: meta - sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c + sha256: "1741988757a65eb6b36abe716829688cf01910bbf91c34354ff7ec1c3de2b349" url: "https://pub.dev" source: hosted - version: "1.16.0" + version: "1.18.0" mime: dependency: transitive description: @@ -832,5 +832,5 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.9.0 <4.0.0" + dart: ">=3.10.0-0 <4.0.0" flutter: ">=3.29.0" diff --git a/packages/graphql_codegen/example/pubspec.yaml b/packages/graphql_codegen/example/pubspec.yaml index a1d02e9b..08e6dc9f 100644 --- a/packages/graphql_codegen/example/pubspec.yaml +++ b/packages/graphql_codegen/example/pubspec.yaml @@ -1,7 +1,7 @@ name: graphql_codegen_example environment: - sdk: ">=2.17.0 <3.0.0" + sdk: ">=3.8.0 <4.0.0" dependencies: graphql_flutter: ^5.2.1 diff --git a/packages/graphql_codegen/lib/src/config/config.dart b/packages/graphql_codegen/lib/src/config/config.dart index 81e24947..8429a0c7 100644 --- a/packages/graphql_codegen/lib/src/config/config.dart +++ b/packages/graphql_codegen/lib/src/config/config.dart @@ -22,7 +22,6 @@ class GraphQLCodegenConfigScalar { this.toJsonFunctionName, }); - @override factory GraphQLCodegenConfigScalar.fromJson(Map json) => _$GraphQLCodegenConfigScalarFromJson(json); @@ -45,7 +44,6 @@ class GraphQLCodegenConfigEnum { required this.fallbackEnumValue, }); - @override factory GraphQLCodegenConfigEnum.fromJson(Map json) => _$GraphQLCodegenConfigEnumFromJson(json); @@ -92,7 +90,6 @@ class GraphQLCodegenConfig { this.setOperationName = false, }); - @override factory GraphQLCodegenConfig.fromJson(Map json) => _$GraphQLCodegenConfigFromJson(json); diff --git a/packages/graphql_codegen/lib/src/transform/transforming_visitor.dart b/packages/graphql_codegen/lib/src/transform/transforming_visitor.dart index 4bb92010..beb56a47 100644 --- a/packages/graphql_codegen/lib/src/transform/transforming_visitor.dart +++ b/packages/graphql_codegen/lib/src/transform/transforming_visitor.dart @@ -194,6 +194,7 @@ class RecursiveTransformingVisitor extends Visitor { description: visitOne(node.description), directives: visitAll(node.directives), fields: visitAll(node.fields), + interfaces: visitAll(node.interfaces), ); } @@ -205,6 +206,7 @@ class RecursiveTransformingVisitor extends Visitor { name: visitOne(node.name), directives: visitAll(node.directives), fields: visitAll(node.fields), + interfaces: visitAll(node.interfaces), ); } diff --git a/packages/graphql_codegen/lib/src/visitor/context_visitor.dart b/packages/graphql_codegen/lib/src/visitor/context_visitor.dart index 2605489e..9e6e45d3 100644 --- a/packages/graphql_codegen/lib/src/visitor/context_visitor.dart +++ b/packages/graphql_codegen/lib/src/visitor/context_visitor.dart @@ -143,25 +143,37 @@ class ContextVisitor extends RecursiveVisitor { _visitInFragment(fragmentDef, fragmentName); return; } - if (context.currentType is! ObjectTypeDefinitionNode) { - return; - } - // Current type condition - final typeCondition = fragmentDef.typeCondition; + if (context.currentType is ObjectTypeDefinitionNode) { + // Current type condition + final typeCondition = fragmentDef.typeCondition; - // Find concrete types of the type conditions. - final typeConditionConcreteTypes = context.schema - .lookupConcreteTypes(typeCondition.on.name) - .map((e) => e.name) - .toSet(); + // Find concrete types of the type conditions. + final typeConditionConcreteTypes = context.schema + .lookupConcreteTypes(typeCondition.on.name) + .map((e) => e.name) + .toSet(); - if (!typeConditionConcreteTypes.contains(context.currentType.name)) { + if (!typeConditionConcreteTypes.contains(context.currentType.name)) { + return; + } + final typedFragmentName = fragmentName.withSegment( + TypeNameSegment(context.currentType.name), + ); + _visitInFragment(fragmentDef, typedFragmentName); return; } - final typedFragmentName = fragmentName.withSegment( - TypeNameSegment(context.currentType.name), - ); - _visitInFragment(fragmentDef, typedFragmentName); + + final currentType = context.currentType; + if (currentType is InterfaceTypeDefinitionNode) { + final typeConditionName = fragmentDef.typeCondition.on.name; + final currentTypeInterfaces = currentType.interfaces + .map((e) => e.name) + .toSet(); + if (!currentTypeInterfaces.contains(typeConditionName)) { + return; + } + _visitInFragment(fragmentDef, fragmentName); + } } @override diff --git a/packages/graphql_codegen/pubspec.lock b/packages/graphql_codegen/pubspec.lock index fdb78710..3bac86c7 100644 --- a/packages/graphql_codegen/pubspec.lock +++ b/packages/graphql_codegen/pubspec.lock @@ -5,18 +5,18 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - sha256: dd3d2ad434b9510001d089e8de7556d50c834481b9abc2891a0184a8493a19dc + sha256: f0bb5d1648339c8308cc0b9838d8456b3cfe5c91f9dc1a735b4d003269e5da9a url: "https://pub.dev" source: hosted - version: "89.0.0" + version: "88.0.0" analyzer: dependency: transitive description: name: analyzer - sha256: c22b6e7726d1f9e5db58c7251606076a71ca0dbcf76116675edfadbec0c9e875 + sha256: "0b7b9c329d2879f8f05d6c05b32ee9ec025f39b077864bdb5ac9a7b63418a98f" url: "https://pub.dev" source: hosted - version: "8.2.0" + version: "8.1.1" args: dependency: transitive description: @@ -698,4 +698,4 @@ packages: source: hosted version: "3.1.3" sdks: - dart: ">=3.9.0 <4.0.0" + dart: ">=3.8.0 <4.0.0" diff --git a/packages/graphql_codegen/pubspec.yaml b/packages/graphql_codegen/pubspec.yaml index 00651991..bd3a8d4b 100644 --- a/packages/graphql_codegen/pubspec.yaml +++ b/packages/graphql_codegen/pubspec.yaml @@ -11,7 +11,7 @@ environment: sdk: ">=3.8.0 <4.0.0" dependencies: - gql: ^1.0.0 + gql: ^1.0.1 build: "^4.0.1" glob: ^2.0.1 code_builder: ^4.2.0 diff --git a/packages/graphql_codegen/test/assets/issue_415/schema.graphql b/packages/graphql_codegen/test/assets/issue_415/schema.graphql new file mode 100644 index 00000000..976c8bfd --- /dev/null +++ b/packages/graphql_codegen/test/assets/issue_415/schema.graphql @@ -0,0 +1,29 @@ +interface Node { + id: ID! +} +interface Animal implements Node { + id: ID! + name: String! +} +type Dog implements Animal & Node { + id: ID! + name: String! + goodBoy: Boolean! +} +type Query { + animal: Animal! +} + +fragment NodeFragment on Node { + id +} +fragment AnimalFragment on Animal { + ...NodeFragment + name +} + +query GetAnimal { + animal { + ...AnimalFragment + } +} diff --git a/packages/graphql_codegen/test/assets/issue_415/schema.graphql.dart b/packages/graphql_codegen/test/assets/issue_415/schema.graphql.dart new file mode 100644 index 00000000..44119759 --- /dev/null +++ b/packages/graphql_codegen/test/assets/issue_415/schema.graphql.dart @@ -0,0 +1,938 @@ +import 'package:gql/ast.dart'; + +enum Enum$__TypeKind { + SCALAR, + OBJECT, + INTERFACE, + UNION, + ENUM, + INPUT_OBJECT, + LIST, + NON_NULL, + $unknown; + + factory Enum$__TypeKind.fromJson(String value) => + fromJson$Enum$__TypeKind(value); + + String toJson() => toJson$Enum$__TypeKind(this); +} + +String toJson$Enum$__TypeKind(Enum$__TypeKind e) { + switch (e) { + case Enum$__TypeKind.SCALAR: + return r'SCALAR'; + case Enum$__TypeKind.OBJECT: + return r'OBJECT'; + case Enum$__TypeKind.INTERFACE: + return r'INTERFACE'; + case Enum$__TypeKind.UNION: + return r'UNION'; + case Enum$__TypeKind.ENUM: + return r'ENUM'; + case Enum$__TypeKind.INPUT_OBJECT: + return r'INPUT_OBJECT'; + case Enum$__TypeKind.LIST: + return r'LIST'; + case Enum$__TypeKind.NON_NULL: + return r'NON_NULL'; + case Enum$__TypeKind.$unknown: + return r'$unknown'; + } +} + +Enum$__TypeKind fromJson$Enum$__TypeKind(String value) { + switch (value) { + case r'SCALAR': + return Enum$__TypeKind.SCALAR; + case r'OBJECT': + return Enum$__TypeKind.OBJECT; + case r'INTERFACE': + return Enum$__TypeKind.INTERFACE; + case r'UNION': + return Enum$__TypeKind.UNION; + case r'ENUM': + return Enum$__TypeKind.ENUM; + case r'INPUT_OBJECT': + return Enum$__TypeKind.INPUT_OBJECT; + case r'LIST': + return Enum$__TypeKind.LIST; + case r'NON_NULL': + return Enum$__TypeKind.NON_NULL; + default: + return Enum$__TypeKind.$unknown; + } +} + +enum Enum$__DirectiveLocation { + QUERY, + MUTATION, + SUBSCRIPTION, + FIELD, + FRAGMENT_DEFINITION, + FRAGMENT_SPREAD, + INLINE_FRAGMENT, + VARIABLE_DEFINITION, + SCHEMA, + SCALAR, + OBJECT, + FIELD_DEFINITION, + ARGUMENT_DEFINITION, + INTERFACE, + UNION, + ENUM, + ENUM_VALUE, + INPUT_OBJECT, + INPUT_FIELD_DEFINITION, + $unknown; + + factory Enum$__DirectiveLocation.fromJson(String value) => + fromJson$Enum$__DirectiveLocation(value); + + String toJson() => toJson$Enum$__DirectiveLocation(this); +} + +String toJson$Enum$__DirectiveLocation(Enum$__DirectiveLocation e) { + switch (e) { + case Enum$__DirectiveLocation.QUERY: + return r'QUERY'; + case Enum$__DirectiveLocation.MUTATION: + return r'MUTATION'; + case Enum$__DirectiveLocation.SUBSCRIPTION: + return r'SUBSCRIPTION'; + case Enum$__DirectiveLocation.FIELD: + return r'FIELD'; + case Enum$__DirectiveLocation.FRAGMENT_DEFINITION: + return r'FRAGMENT_DEFINITION'; + case Enum$__DirectiveLocation.FRAGMENT_SPREAD: + return r'FRAGMENT_SPREAD'; + case Enum$__DirectiveLocation.INLINE_FRAGMENT: + return r'INLINE_FRAGMENT'; + case Enum$__DirectiveLocation.VARIABLE_DEFINITION: + return r'VARIABLE_DEFINITION'; + case Enum$__DirectiveLocation.SCHEMA: + return r'SCHEMA'; + case Enum$__DirectiveLocation.SCALAR: + return r'SCALAR'; + case Enum$__DirectiveLocation.OBJECT: + return r'OBJECT'; + case Enum$__DirectiveLocation.FIELD_DEFINITION: + return r'FIELD_DEFINITION'; + case Enum$__DirectiveLocation.ARGUMENT_DEFINITION: + return r'ARGUMENT_DEFINITION'; + case Enum$__DirectiveLocation.INTERFACE: + return r'INTERFACE'; + case Enum$__DirectiveLocation.UNION: + return r'UNION'; + case Enum$__DirectiveLocation.ENUM: + return r'ENUM'; + case Enum$__DirectiveLocation.ENUM_VALUE: + return r'ENUM_VALUE'; + case Enum$__DirectiveLocation.INPUT_OBJECT: + return r'INPUT_OBJECT'; + case Enum$__DirectiveLocation.INPUT_FIELD_DEFINITION: + return r'INPUT_FIELD_DEFINITION'; + case Enum$__DirectiveLocation.$unknown: + return r'$unknown'; + } +} + +Enum$__DirectiveLocation fromJson$Enum$__DirectiveLocation(String value) { + switch (value) { + case r'QUERY': + return Enum$__DirectiveLocation.QUERY; + case r'MUTATION': + return Enum$__DirectiveLocation.MUTATION; + case r'SUBSCRIPTION': + return Enum$__DirectiveLocation.SUBSCRIPTION; + case r'FIELD': + return Enum$__DirectiveLocation.FIELD; + case r'FRAGMENT_DEFINITION': + return Enum$__DirectiveLocation.FRAGMENT_DEFINITION; + case r'FRAGMENT_SPREAD': + return Enum$__DirectiveLocation.FRAGMENT_SPREAD; + case r'INLINE_FRAGMENT': + return Enum$__DirectiveLocation.INLINE_FRAGMENT; + case r'VARIABLE_DEFINITION': + return Enum$__DirectiveLocation.VARIABLE_DEFINITION; + case r'SCHEMA': + return Enum$__DirectiveLocation.SCHEMA; + case r'SCALAR': + return Enum$__DirectiveLocation.SCALAR; + case r'OBJECT': + return Enum$__DirectiveLocation.OBJECT; + case r'FIELD_DEFINITION': + return Enum$__DirectiveLocation.FIELD_DEFINITION; + case r'ARGUMENT_DEFINITION': + return Enum$__DirectiveLocation.ARGUMENT_DEFINITION; + case r'INTERFACE': + return Enum$__DirectiveLocation.INTERFACE; + case r'UNION': + return Enum$__DirectiveLocation.UNION; + case r'ENUM': + return Enum$__DirectiveLocation.ENUM; + case r'ENUM_VALUE': + return Enum$__DirectiveLocation.ENUM_VALUE; + case r'INPUT_OBJECT': + return Enum$__DirectiveLocation.INPUT_OBJECT; + case r'INPUT_FIELD_DEFINITION': + return Enum$__DirectiveLocation.INPUT_FIELD_DEFINITION; + default: + return Enum$__DirectiveLocation.$unknown; + } +} + +class Fragment$NodeFragment { + Fragment$NodeFragment({required this.id, required this.$__typename}); + + factory Fragment$NodeFragment.fromJson(Map json) { + switch (json["__typename"] as String) { + case "Dog": + return Fragment$NodeFragment$$Dog.fromJson(json); + + default: + final l$id = json['id']; + final l$$__typename = json['__typename']; + return Fragment$NodeFragment( + id: (l$id as String), + $__typename: (l$$__typename as String), + ); + } + } + + final String id; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$id = id; + _resultData['id'] = l$id; + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$id = id; + final l$$__typename = $__typename; + return Object.hashAll([l$id, l$$__typename]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (other is! Fragment$NodeFragment || runtimeType != other.runtimeType) { + return false; + } + final l$id = id; + final lOther$id = other.id; + if (l$id != lOther$id) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Fragment$NodeFragment on Fragment$NodeFragment { + CopyWith$Fragment$NodeFragment get copyWith => + CopyWith$Fragment$NodeFragment(this, (i) => i); + + _T when<_T>({ + required _T Function(Fragment$NodeFragment$$Dog) dog, + required _T Function() orElse, + }) { + switch ($__typename) { + case "Dog": + return dog(this as Fragment$NodeFragment$$Dog); + + default: + return orElse(); + } + } + + _T maybeWhen<_T>({ + _T Function(Fragment$NodeFragment$$Dog)? dog, + required _T Function() orElse, + }) { + switch ($__typename) { + case "Dog": + if (dog != null) { + return dog(this as Fragment$NodeFragment$$Dog); + } else { + return orElse(); + } + + default: + return orElse(); + } + } +} + +abstract class CopyWith$Fragment$NodeFragment { + factory CopyWith$Fragment$NodeFragment( + Fragment$NodeFragment instance, + TRes Function(Fragment$NodeFragment) then, + ) = _CopyWithImpl$Fragment$NodeFragment; + + factory CopyWith$Fragment$NodeFragment.stub(TRes res) = + _CopyWithStubImpl$Fragment$NodeFragment; + + TRes call({String? id, String? $__typename}); +} + +class _CopyWithImpl$Fragment$NodeFragment + implements CopyWith$Fragment$NodeFragment { + _CopyWithImpl$Fragment$NodeFragment(this._instance, this._then); + + final Fragment$NodeFragment _instance; + + final TRes Function(Fragment$NodeFragment) _then; + + static const _undefined = {}; + + TRes call({Object? id = _undefined, Object? $__typename = _undefined}) => + _then( + Fragment$NodeFragment( + id: id == _undefined || id == null ? _instance.id : (id as String), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + ), + ); +} + +class _CopyWithStubImpl$Fragment$NodeFragment + implements CopyWith$Fragment$NodeFragment { + _CopyWithStubImpl$Fragment$NodeFragment(this._res); + + TRes _res; + + call({String? id, String? $__typename}) => _res; +} + +const fragmentDefinitionNodeFragment = FragmentDefinitionNode( + name: NameNode(value: 'NodeFragment'), + typeCondition: TypeConditionNode( + on: NamedTypeNode(name: NameNode(value: 'Node'), isNonNull: false), + ), + directives: [], + selectionSet: SelectionSetNode( + selections: [ + FieldNode( + name: NameNode(value: 'id'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ], + ), +); +const documentNodeFragmentNodeFragment = DocumentNode( + definitions: [fragmentDefinitionNodeFragment], +); + +class Fragment$NodeFragment$$Dog implements Fragment$NodeFragment { + Fragment$NodeFragment$$Dog({required this.id, this.$__typename = 'Dog'}); + + factory Fragment$NodeFragment$$Dog.fromJson(Map json) { + final l$id = json['id']; + final l$$__typename = json['__typename']; + return Fragment$NodeFragment$$Dog( + id: (l$id as String), + $__typename: (l$$__typename as String), + ); + } + + final String id; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$id = id; + _resultData['id'] = l$id; + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$id = id; + final l$$__typename = $__typename; + return Object.hashAll([l$id, l$$__typename]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (other is! Fragment$NodeFragment$$Dog || + runtimeType != other.runtimeType) { + return false; + } + final l$id = id; + final lOther$id = other.id; + if (l$id != lOther$id) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Fragment$NodeFragment$$Dog + on Fragment$NodeFragment$$Dog { + CopyWith$Fragment$NodeFragment$$Dog + get copyWith => CopyWith$Fragment$NodeFragment$$Dog(this, (i) => i); +} + +abstract class CopyWith$Fragment$NodeFragment$$Dog { + factory CopyWith$Fragment$NodeFragment$$Dog( + Fragment$NodeFragment$$Dog instance, + TRes Function(Fragment$NodeFragment$$Dog) then, + ) = _CopyWithImpl$Fragment$NodeFragment$$Dog; + + factory CopyWith$Fragment$NodeFragment$$Dog.stub(TRes res) = + _CopyWithStubImpl$Fragment$NodeFragment$$Dog; + + TRes call({String? id, String? $__typename}); +} + +class _CopyWithImpl$Fragment$NodeFragment$$Dog + implements CopyWith$Fragment$NodeFragment$$Dog { + _CopyWithImpl$Fragment$NodeFragment$$Dog(this._instance, this._then); + + final Fragment$NodeFragment$$Dog _instance; + + final TRes Function(Fragment$NodeFragment$$Dog) _then; + + static const _undefined = {}; + + TRes call({Object? id = _undefined, Object? $__typename = _undefined}) => + _then( + Fragment$NodeFragment$$Dog( + id: id == _undefined || id == null ? _instance.id : (id as String), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + ), + ); +} + +class _CopyWithStubImpl$Fragment$NodeFragment$$Dog + implements CopyWith$Fragment$NodeFragment$$Dog { + _CopyWithStubImpl$Fragment$NodeFragment$$Dog(this._res); + + TRes _res; + + call({String? id, String? $__typename}) => _res; +} + +class Fragment$AnimalFragment implements Fragment$NodeFragment { + Fragment$AnimalFragment({ + required this.id, + required this.$__typename, + required this.name, + }); + + factory Fragment$AnimalFragment.fromJson(Map json) { + switch (json["__typename"] as String) { + case "Dog": + return Fragment$AnimalFragment$$Dog.fromJson(json); + + default: + final l$id = json['id']; + final l$$__typename = json['__typename']; + final l$name = json['name']; + return Fragment$AnimalFragment( + id: (l$id as String), + $__typename: (l$$__typename as String), + name: (l$name as String), + ); + } + } + + final String id; + + final String $__typename; + + final String name; + + Map toJson() { + final _resultData = {}; + final l$id = id; + _resultData['id'] = l$id; + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + final l$name = name; + _resultData['name'] = l$name; + return _resultData; + } + + @override + int get hashCode { + final l$id = id; + final l$$__typename = $__typename; + final l$name = name; + return Object.hashAll([l$id, l$$__typename, l$name]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (other is! Fragment$AnimalFragment || runtimeType != other.runtimeType) { + return false; + } + final l$id = id; + final lOther$id = other.id; + if (l$id != lOther$id) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + final l$name = name; + final lOther$name = other.name; + if (l$name != lOther$name) { + return false; + } + return true; + } +} + +extension UtilityExtension$Fragment$AnimalFragment on Fragment$AnimalFragment { + CopyWith$Fragment$AnimalFragment get copyWith => + CopyWith$Fragment$AnimalFragment(this, (i) => i); + + _T when<_T>({ + required _T Function(Fragment$AnimalFragment$$Dog) dog, + required _T Function() orElse, + }) { + switch ($__typename) { + case "Dog": + return dog(this as Fragment$AnimalFragment$$Dog); + + default: + return orElse(); + } + } + + _T maybeWhen<_T>({ + _T Function(Fragment$AnimalFragment$$Dog)? dog, + required _T Function() orElse, + }) { + switch ($__typename) { + case "Dog": + if (dog != null) { + return dog(this as Fragment$AnimalFragment$$Dog); + } else { + return orElse(); + } + + default: + return orElse(); + } + } +} + +abstract class CopyWith$Fragment$AnimalFragment { + factory CopyWith$Fragment$AnimalFragment( + Fragment$AnimalFragment instance, + TRes Function(Fragment$AnimalFragment) then, + ) = _CopyWithImpl$Fragment$AnimalFragment; + + factory CopyWith$Fragment$AnimalFragment.stub(TRes res) = + _CopyWithStubImpl$Fragment$AnimalFragment; + + TRes call({String? id, String? $__typename, String? name}); +} + +class _CopyWithImpl$Fragment$AnimalFragment + implements CopyWith$Fragment$AnimalFragment { + _CopyWithImpl$Fragment$AnimalFragment(this._instance, this._then); + + final Fragment$AnimalFragment _instance; + + final TRes Function(Fragment$AnimalFragment) _then; + + static const _undefined = {}; + + TRes call({ + Object? id = _undefined, + Object? $__typename = _undefined, + Object? name = _undefined, + }) => _then( + Fragment$AnimalFragment( + id: id == _undefined || id == null ? _instance.id : (id as String), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + name: name == _undefined || name == null + ? _instance.name + : (name as String), + ), + ); +} + +class _CopyWithStubImpl$Fragment$AnimalFragment + implements CopyWith$Fragment$AnimalFragment { + _CopyWithStubImpl$Fragment$AnimalFragment(this._res); + + TRes _res; + + call({String? id, String? $__typename, String? name}) => _res; +} + +const fragmentDefinitionAnimalFragment = FragmentDefinitionNode( + name: NameNode(value: 'AnimalFragment'), + typeCondition: TypeConditionNode( + on: NamedTypeNode(name: NameNode(value: 'Animal'), isNonNull: false), + ), + directives: [], + selectionSet: SelectionSetNode( + selections: [ + FragmentSpreadNode( + name: NameNode(value: 'NodeFragment'), + directives: [], + ), + FieldNode( + name: NameNode(value: 'name'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ], + ), +); +const documentNodeFragmentAnimalFragment = DocumentNode( + definitions: [ + fragmentDefinitionAnimalFragment, + fragmentDefinitionNodeFragment, + ], +); + +class Fragment$AnimalFragment$$Dog + implements Fragment$NodeFragment$$Dog, Fragment$AnimalFragment { + Fragment$AnimalFragment$$Dog({ + required this.id, + this.$__typename = 'Dog', + required this.name, + }); + + factory Fragment$AnimalFragment$$Dog.fromJson(Map json) { + final l$id = json['id']; + final l$$__typename = json['__typename']; + final l$name = json['name']; + return Fragment$AnimalFragment$$Dog( + id: (l$id as String), + $__typename: (l$$__typename as String), + name: (l$name as String), + ); + } + + final String id; + + final String $__typename; + + final String name; + + Map toJson() { + final _resultData = {}; + final l$id = id; + _resultData['id'] = l$id; + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + final l$name = name; + _resultData['name'] = l$name; + return _resultData; + } + + @override + int get hashCode { + final l$id = id; + final l$$__typename = $__typename; + final l$name = name; + return Object.hashAll([l$id, l$$__typename, l$name]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (other is! Fragment$AnimalFragment$$Dog || + runtimeType != other.runtimeType) { + return false; + } + final l$id = id; + final lOther$id = other.id; + if (l$id != lOther$id) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + final l$name = name; + final lOther$name = other.name; + if (l$name != lOther$name) { + return false; + } + return true; + } +} + +extension UtilityExtension$Fragment$AnimalFragment$$Dog + on Fragment$AnimalFragment$$Dog { + CopyWith$Fragment$AnimalFragment$$Dog + get copyWith => CopyWith$Fragment$AnimalFragment$$Dog(this, (i) => i); +} + +abstract class CopyWith$Fragment$AnimalFragment$$Dog { + factory CopyWith$Fragment$AnimalFragment$$Dog( + Fragment$AnimalFragment$$Dog instance, + TRes Function(Fragment$AnimalFragment$$Dog) then, + ) = _CopyWithImpl$Fragment$AnimalFragment$$Dog; + + factory CopyWith$Fragment$AnimalFragment$$Dog.stub(TRes res) = + _CopyWithStubImpl$Fragment$AnimalFragment$$Dog; + + TRes call({String? id, String? $__typename, String? name}); +} + +class _CopyWithImpl$Fragment$AnimalFragment$$Dog + implements CopyWith$Fragment$AnimalFragment$$Dog { + _CopyWithImpl$Fragment$AnimalFragment$$Dog(this._instance, this._then); + + final Fragment$AnimalFragment$$Dog _instance; + + final TRes Function(Fragment$AnimalFragment$$Dog) _then; + + static const _undefined = {}; + + TRes call({ + Object? id = _undefined, + Object? $__typename = _undefined, + Object? name = _undefined, + }) => _then( + Fragment$AnimalFragment$$Dog( + id: id == _undefined || id == null ? _instance.id : (id as String), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + name: name == _undefined || name == null + ? _instance.name + : (name as String), + ), + ); +} + +class _CopyWithStubImpl$Fragment$AnimalFragment$$Dog + implements CopyWith$Fragment$AnimalFragment$$Dog { + _CopyWithStubImpl$Fragment$AnimalFragment$$Dog(this._res); + + TRes _res; + + call({String? id, String? $__typename, String? name}) => _res; +} + +class Query$GetAnimal { + Query$GetAnimal({required this.animal, this.$__typename = 'Query'}); + + factory Query$GetAnimal.fromJson(Map json) { + final l$animal = json['animal']; + final l$$__typename = json['__typename']; + return Query$GetAnimal( + animal: Fragment$AnimalFragment.fromJson( + (l$animal as Map), + ), + $__typename: (l$$__typename as String), + ); + } + + final Fragment$AnimalFragment animal; + + final String $__typename; + + Map toJson() { + final _resultData = {}; + final l$animal = animal; + _resultData['animal'] = l$animal.toJson(); + final l$$__typename = $__typename; + _resultData['__typename'] = l$$__typename; + return _resultData; + } + + @override + int get hashCode { + final l$animal = animal; + final l$$__typename = $__typename; + return Object.hashAll([l$animal, l$$__typename]); + } + + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (other is! Query$GetAnimal || runtimeType != other.runtimeType) { + return false; + } + final l$animal = animal; + final lOther$animal = other.animal; + if (l$animal != lOther$animal) { + return false; + } + final l$$__typename = $__typename; + final lOther$$__typename = other.$__typename; + if (l$$__typename != lOther$$__typename) { + return false; + } + return true; + } +} + +extension UtilityExtension$Query$GetAnimal on Query$GetAnimal { + CopyWith$Query$GetAnimal get copyWith => + CopyWith$Query$GetAnimal(this, (i) => i); +} + +abstract class CopyWith$Query$GetAnimal { + factory CopyWith$Query$GetAnimal( + Query$GetAnimal instance, + TRes Function(Query$GetAnimal) then, + ) = _CopyWithImpl$Query$GetAnimal; + + factory CopyWith$Query$GetAnimal.stub(TRes res) = + _CopyWithStubImpl$Query$GetAnimal; + + TRes call({Fragment$AnimalFragment? animal, String? $__typename}); + CopyWith$Fragment$AnimalFragment get animal; +} + +class _CopyWithImpl$Query$GetAnimal + implements CopyWith$Query$GetAnimal { + _CopyWithImpl$Query$GetAnimal(this._instance, this._then); + + final Query$GetAnimal _instance; + + final TRes Function(Query$GetAnimal) _then; + + static const _undefined = {}; + + TRes call({Object? animal = _undefined, Object? $__typename = _undefined}) => + _then( + Query$GetAnimal( + animal: animal == _undefined || animal == null + ? _instance.animal + : (animal as Fragment$AnimalFragment), + $__typename: $__typename == _undefined || $__typename == null + ? _instance.$__typename + : ($__typename as String), + ), + ); + + CopyWith$Fragment$AnimalFragment get animal { + final local$animal = _instance.animal; + return CopyWith$Fragment$AnimalFragment( + local$animal, + (e) => call(animal: e), + ); + } +} + +class _CopyWithStubImpl$Query$GetAnimal + implements CopyWith$Query$GetAnimal { + _CopyWithStubImpl$Query$GetAnimal(this._res); + + TRes _res; + + call({Fragment$AnimalFragment? animal, String? $__typename}) => _res; + + CopyWith$Fragment$AnimalFragment get animal => + CopyWith$Fragment$AnimalFragment.stub(_res); +} + +const documentNodeQueryGetAnimal = DocumentNode( + definitions: [ + OperationDefinitionNode( + type: OperationType.query, + name: NameNode(value: 'GetAnimal'), + variableDefinitions: [], + directives: [], + selectionSet: SelectionSetNode( + selections: [ + FieldNode( + name: NameNode(value: 'animal'), + alias: null, + arguments: [], + directives: [], + selectionSet: SelectionSetNode( + selections: [ + FragmentSpreadNode( + name: NameNode(value: 'AnimalFragment'), + directives: [], + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ], + ), + ), + FieldNode( + name: NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ], + ), + ), + fragmentDefinitionAnimalFragment, + fragmentDefinitionNodeFragment, + ], +); +const possibleTypesMap = >{ + 'Animal': {'Dog'}, + 'Node': {'Dog'}, +}; diff --git a/pubspec.lock b/pubspec.lock index 3e7d7e6b..fe8c8325 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -13,18 +13,18 @@ packages: dependency: transitive description: name: args - sha256: bf9f5caeea8d8fe6721a9c358dd8a5c1947b27f1cfaa18b39c301273594919e6 + sha256: d0481093c50b1da8910eb0bb301626d4d8eb7284aa739614d2b394ee09e3ea04 url: "https://pub.dev" source: hosted - version: "2.6.0" + version: "2.7.0" async: dependency: transitive description: name: async - sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 + sha256: e2eb0491ba5ddb6177742d2da23904574082139b07c1e33b8503b9f46f3e1a37 url: "https://pub.dev" source: hosted - version: "2.12.0" + version: "2.13.1" charcode: dependency: transitive description: @@ -45,10 +45,10 @@ packages: dependency: transitive description: name: cli_launcher - sha256: "5e7e0282b79e8642edd6510ee468ae2976d847a0a29b3916e85f5fa1bfe24005" + sha256: "35cf15a3ffaeb9c11849eaa0afba761bb76dceb42d050532bfd3e1299c9748cd" url: "https://pub.dev" source: hosted - version: "0.3.1" + version: "0.3.3+1" cli_util: dependency: transitive description: @@ -57,14 +57,6 @@ packages: url: "https://pub.dev" source: hosted version: "0.4.2" - clock: - dependency: transitive - description: - name: clock - sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b - url: "https://pub.dev" - source: hosted - version: "1.1.2" collection: dependency: transitive description: @@ -77,10 +69,10 @@ packages: dependency: transitive description: name: conventional_commit - sha256: dec15ad1118f029c618651a4359eb9135d8b88f761aa24e4016d061cd45948f2 + sha256: c40b1b449ce2a63fa2ce852f35e3890b1e182f5951819934c0e4a66254bc0dc3 url: "https://pub.dev" source: hosted - version: "0.6.0+1" + version: "0.6.1+1" file: dependency: transitive description: @@ -109,10 +101,10 @@ packages: dependency: transitive description: name: http - sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f + sha256: "87721a4a50b19c7f1d49001e51409bddc46303966ce89a65af4f4e6004896412" url: "https://pub.dev" source: hosted - version: "1.3.0" + version: "1.6.0" http_parser: dependency: transitive description: @@ -121,14 +113,6 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.2" - intl: - dependency: transitive - description: - name: intl - sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf - url: "https://pub.dev" - source: hosted - version: "0.19.0" io: dependency: transitive description: @@ -149,10 +133,10 @@ packages: dependency: "direct dev" description: name: melos - sha256: "3f3ab3f902843d1e5a1b1a4dd39a4aca8ba1056f2d32fd8995210fa2843f646f" + sha256: "4280dc46bd5b741887cce1e67e5c1a6aaf3c22310035cf5bd33dceeeda62ed22" url: "https://pub.dev" source: hosted - version: "6.3.2" + version: "6.3.3" meta: dependency: transitive description: @@ -213,18 +197,18 @@ packages: dependency: transitive description: name: pub_semver - sha256: "7b3cfbf654f3edd0c6298ecd5be782ce997ddf0e00531b9464b55245185bbbbd" + sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" url: "https://pub.dev" source: hosted - version: "2.1.5" + version: "2.2.0" pub_updater: dependency: transitive description: name: pub_updater - sha256: "54e8dc865349059ebe7f163d6acce7c89eb958b8047e6d6e80ce93b13d7c9e60" + sha256: "739a0161d73a6974c0675b864fb0cf5147305f7b077b7f03a58fa7a9ab3e7e7d" url: "https://pub.dev" source: hosted - version: "0.4.0" + version: "0.5.0" pubspec_parse: dependency: transitive description: @@ -298,4 +282,4 @@ packages: source: hosted version: "2.2.2" sdks: - dart: ">=3.6.0 <4.0.0" + dart: ">=3.8.0 <4.0.0"