From 7b3976f6d4500926657f4ba2f3f72ae5ea59f604 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 7 Jan 2024 02:03:19 +0000 Subject: [PATCH 01/12] Revert "[gql_code_builder] add dataClassConfig option to reuse class definitions for field selections that include only a single inline fragment spread" This reverts commit 276032edac651ea3e6e58876237e1f9df657bcd8. --- codegen/gql_build/lib/gql_build.dart | 14 +- codegen/gql_build/lib/src/data_builder.dart | 16 +- codegen/gql_build/lib/src/utils/config.dart | 4 - codegen/gql_code_builder/lib/data.dart | 152 ------------------ .../gql_code_builder/lib/src/built_class.dart | 17 +- codegen/gql_code_builder/lib/src/common.dart | 5 +- .../lib/src/config/data_class_config.dart | 8 - .../lib/src/inline_fragment_classes.dart | 82 ++++------ .../lib/src/operation/data.dart | 120 +++----------- .../lib/src/when_extension.dart | 10 +- 10 files changed, 71 insertions(+), 357 deletions(-) delete mode 100644 codegen/gql_code_builder/lib/src/config/data_class_config.dart diff --git a/codegen/gql_build/lib/gql_build.dart b/codegen/gql_build/lib/gql_build.dart index cb4bf28b..166898d6 100644 --- a/codegen/gql_build/lib/gql_build.dart +++ b/codegen/gql_build/lib/gql_build.dart @@ -19,14 +19,12 @@ Builder dataBuilder( BuilderOptions options, ) => DataBuilder( - AssetId.parse( - options.config["schema"] as String, - ), - (options.config["add_typenames"] ?? true) as bool, - typeOverrideMap(options.config["type_overrides"]), - whenExtensionConfig: whenExtensionConfig(options.config), - dataClassConfig: dataClassConfig(options.config), - ); + AssetId.parse( + options.config["schema"] as String, + ), + (options.config["add_typenames"] ?? true) as bool, + typeOverrideMap(options.config["type_overrides"]), + whenExtensionConfig: whenExtensionConfig(options.config)); /// Builds GraphQL type-safe request builder Builder reqBuilder( diff --git a/codegen/gql_build/lib/src/data_builder.dart b/codegen/gql_build/lib/src/data_builder.dart index f81b0fff..641c17a3 100644 --- a/codegen/gql_build/lib/src/data_builder.dart +++ b/codegen/gql_build/lib/src/data_builder.dart @@ -14,7 +14,6 @@ class DataBuilder implements Builder { final bool addTypenames; final Map typeOverrides; final InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig; - final DataClassConfig dataClassConfig; DataBuilder( this.schemaId, @@ -24,9 +23,6 @@ class DataBuilder implements Builder { generateWhenExtensionMethod: false, generateMaybeWhenExtensionMethod: false, ), - this.dataClassConfig = const DataClassConfig( - reuseFragments: false, - ), }); @override @@ -45,13 +41,11 @@ class DataBuilder implements Builder { .path; final library = buildDataLibrary( - addTypenames ? introspection.addTypenames(doc) : doc, - introspection.addTypenames(schema), - basename(generatedPartUrl), - typeOverrides, - whenExtensionConfig, - dataClassConfig, - ); + addTypenames ? introspection.addTypenames(doc) : doc, + introspection.addTypenames(schema), + basename(generatedPartUrl), + typeOverrides, + whenExtensionConfig); return writeDocument( library, diff --git a/codegen/gql_build/lib/src/utils/config.dart b/codegen/gql_build/lib/src/utils/config.dart index d5b7b7b0..d9805d0e 100644 --- a/codegen/gql_build/lib/src/utils/config.dart +++ b/codegen/gql_build/lib/src/utils/config.dart @@ -42,10 +42,6 @@ EnumFallbackConfig enumFallbackConfig(Map config) => fallbackValueMap: enumFallbackMap(config["enum_fallbacks"]), ); -DataClassConfig dataClassConfig(Map config) => DataClassConfig( - reuseFragments: config["reuse_fragments"] == true, - ); - InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig( Map config) { final whenYamlConfig = config["when_extensions"] as YamlMap?; diff --git a/codegen/gql_code_builder/lib/data.dart b/codegen/gql_code_builder/lib/data.dart index dff7f16b..b64d6607 100644 --- a/codegen/gql_code_builder/lib/data.dart +++ b/codegen/gql_code_builder/lib/data.dart @@ -1,14 +1,11 @@ import "package:built_collection/built_collection.dart"; import "package:code_builder/code_builder.dart"; import "package:gql/ast.dart"; -import "package:gql_code_builder/src/common.dart"; -import "package:gql_code_builder/src/config/data_class_config.dart"; import "package:gql_code_builder/src/config/when_extension_config.dart"; import "./source.dart"; import "./src/operation/data.dart"; -export "package:gql_code_builder/src/config/data_class_config.dart"; export "package:gql_code_builder/src/config/when_extension_config.dart"; Library buildDataLibrary( @@ -21,15 +18,7 @@ Library buildDataLibrary( generateWhenExtensionMethod: false, generateMaybeWhenExtensionMethod: false, ), - DataClassConfig dataClassConfig = const DataClassConfig( - reuseFragments: false, - ), ]) { - final fragmentMap = _fragmentMap(docSource); - final dataClassAliasMap = dataClassConfig.reuseFragments - ? _dataClassAliasMap(docSource, fragmentMap) - : {}; - final operationDataClasses = docSource.document.definitions .whereType() .expand( @@ -39,8 +28,6 @@ Library buildDataLibrary( schemaSource, typeOverrides, whenExtensionConfig, - fragmentMap, - dataClassAliasMap, ), ) .toList(); @@ -54,8 +41,6 @@ Library buildDataLibrary( schemaSource, typeOverrides, whenExtensionConfig, - fragmentMap, - dataClassAliasMap, ), ) .toList(); @@ -69,140 +54,3 @@ Library buildDataLibrary( ]), ); } - -Map _fragmentMap(SourceNode source) => { - for (final def - in source.document.definitions.whereType()) - def.name.value: SourceSelections( - url: source.url, - selections: def.selectionSet.selections, - ), - for (final import in source.imports) ..._fragmentMap(import) - }; - -Map _dataClassAliasMap( - SourceNode source, Map fragmentMap, - [Map? aliasMap, Set? visitedSource]) { - aliasMap ??= {}; - visitedSource ??= {}; - - source.imports.forEach((s) { - if (!visitedSource!.contains(source.url)) { - visitedSource.add(source.url); - _dataClassAliasMap(s, fragmentMap, aliasMap); - } - }); - - for (final def - in source.document.definitions.whereType()) { - _dataClassAliasMapDFS( - typeRefPrefix: builtClassName("${def.name!.value}Data"), - getAliasTypeName: (fragmentName) => "${builtClassName(fragmentName)}Data", - selections: def.selectionSet.selections, - fragmentMap: fragmentMap, - aliasMap: aliasMap, - ); - } - - for (final def - in source.document.definitions.whereType()) { - _dataClassAliasMapDFS( - typeRefPrefix: builtClassName(def.name.value), - getAliasTypeName: builtClassName, - selections: def.selectionSet.selections, - fragmentMap: fragmentMap, - aliasMap: aliasMap, - ); - _dataClassAliasMapDFS( - typeRefPrefix: builtClassName("${def.name.value}Data"), - getAliasTypeName: (fragmentName) => "${builtClassName(fragmentName)}Data", - selections: def.selectionSet.selections, - fragmentMap: fragmentMap, - aliasMap: aliasMap, - ); - } - - return aliasMap; -} - -void _dataClassAliasMapDFS({ - required String typeRefPrefix, - required String Function(String fragmentName) getAliasTypeName, - required List selections, - required Map fragmentMap, - required Map aliasMap, -}) { - if (selections.isEmpty) return; - - // flatten selections to extract untouched fragments while visiting children. - final shrunkenSelections = - shrinkSelections(mergeSelections(selections, fragmentMap), fragmentMap); - - // alias single fragment and finish - final selectionsWithoutTypename = shrunkenSelections - .where((s) => !(s is FieldNode && s.name.value == "__typename")); - if (selectionsWithoutTypename.length == 1 && - selectionsWithoutTypename.first is FragmentSpreadNode) { - final node = selectionsWithoutTypename.first as FragmentSpreadNode; - final fragment = fragmentMap[node.name.value]; - final fragmentTypeName = getAliasTypeName(node.name.value); - aliasMap[typeRefPrefix] = - refer(fragmentTypeName, "${fragment!.url ?? ""}#data"); - // print("alias $typeRefPrefix => $fragmentTypeName"); - return; - } - - for (final node in selectionsWithoutTypename) { - if (node is FragmentSpreadNode) { - // exclude redefined selections from each fragment selections - final fragmentSelections = fragmentMap[node.name.value]!.selections; - final exclusiveFragmentSelections = - mergeSelections(fragmentSelections, fragmentMap).where((s1) { - if (s1 is FieldNode) { - final name = (s1.alias ?? s1.name).value; - return selectionsWithoutTypename - .whereType() - .every((s2) => name != (s2.alias ?? s2.name).value); - } else if (s1 is InlineFragmentNode && s1.typeCondition != null) { - /// TODO: Handle inline fragments without a type condition - final name = s1.typeCondition!.on.name.value; - return selectionsWithoutTypename - .whereType() - .every((s2) => name != s2.typeCondition?.on.name.value); - } - return false; - }).toList(); - - _dataClassAliasMapDFS( - typeRefPrefix: typeRefPrefix, - getAliasTypeName: getAliasTypeName, - selections: exclusiveFragmentSelections, - fragmentMap: fragmentMap, - aliasMap: aliasMap, - ); - } else if (node is InlineFragmentNode) { - if (node.typeCondition != null) { - /// TODO: Handle inline fragments without a type condition - _dataClassAliasMapDFS( - typeRefPrefix: - "${typeRefPrefix}__as${node.typeCondition!.on.name.value}", - getAliasTypeName: getAliasTypeName, - selections: [ - ...selections.where((s) => s != node), - ...node.selectionSet.selections, - ], - fragmentMap: fragmentMap, - aliasMap: aliasMap, - ); - } - } else if (node is FieldNode && node.selectionSet != null) { - _dataClassAliasMapDFS( - typeRefPrefix: "${typeRefPrefix}_${(node.alias ?? node.name).value}", - getAliasTypeName: getAliasTypeName, - selections: node.selectionSet!.selections, - fragmentMap: fragmentMap, - aliasMap: aliasMap, - ); - } - } -} diff --git a/codegen/gql_code_builder/lib/src/built_class.dart b/codegen/gql_code_builder/lib/src/built_class.dart index 44673628..a6e0cba8 100644 --- a/codegen/gql_code_builder/lib/src/built_class.dart +++ b/codegen/gql_code_builder/lib/src/built_class.dart @@ -11,7 +11,6 @@ Class builtClass({ Map? initializers, Map superclassSelections = const {}, List methods = const [], - Map? dataClassAliasMap, bool hasCustomSerializer = false, }) { final className = builtClassName(name); @@ -32,16 +31,12 @@ Class builtClass({ ], ), ), - ...superclassSelections.keys - .where((superName) => - dataClassAliasMap?.containsKey(builtClassName(superName)) != - true) - .map( - (superName) => refer( - builtClassName(superName), - (superclassSelections[superName]?.url ?? "") + "#data", - ), - ) + ...superclassSelections.keys.map( + (superName) => refer( + builtClassName(superName), + (superclassSelections[superName]?.url ?? "") + "#data", + ), + ) ], ) ..constructors.addAll( diff --git a/codegen/gql_code_builder/lib/src/common.dart b/codegen/gql_code_builder/lib/src/common.dart index 4197daf4..77e6168b 100644 --- a/codegen/gql_code_builder/lib/src/common.dart +++ b/codegen/gql_code_builder/lib/src/common.dart @@ -138,7 +138,6 @@ Method buildGetter({ required TypeNode typeNode, required SourceNode schemaSource, Map typeOverrides = const {}, - Reference? typeRefAlias, String? typeRefPrefix, bool built = true, bool isOverride = false, @@ -152,9 +151,7 @@ Method buildGetter({ final typeMap = { ...defaultTypeMap, - if (typeRefAlias != null) - typeName: typeRefAlias - else if (typeRefPrefix != null) + if (typeRefPrefix != null) typeName: refer("${typeRefPrefix}_${nameNode.value}") else if (typeDef != null) typeName: refer( diff --git a/codegen/gql_code_builder/lib/src/config/data_class_config.dart b/codegen/gql_code_builder/lib/src/config/data_class_config.dart deleted file mode 100644 index 65a399e5..00000000 --- a/codegen/gql_code_builder/lib/src/config/data_class_config.dart +++ /dev/null @@ -1,8 +0,0 @@ -/// config for the optimization of data class generation. -class DataClassConfig { - final bool reuseFragments; - - const DataClassConfig({ - required this.reuseFragments, - }); -} diff --git a/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart b/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart index 37fe603c..cb49a696 100644 --- a/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart +++ b/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart @@ -22,7 +22,6 @@ List buildInlineFragmentClasses({ required String type, required Map typeOverrides, required Map fragmentMap, - required Map dataClassAliasMap, required Map superclassSelections, required List inlineFragments, required bool built, @@ -32,7 +31,6 @@ List buildInlineFragmentClasses({ baseTypeName: name, inlineFragments: inlineFragments, config: whenExtensionConfig, - dataClassAliasMap: dataClassAliasMap, ); return [ Class( @@ -40,15 +38,12 @@ List buildInlineFragmentClasses({ ..abstract = true ..name = builtClassName(name) ..implements.addAll( - superclassSelections.keys - .where((superName) => - !dataClassAliasMap.containsKey(builtClassName(superName))) - .map( - (superName) => refer( - builtClassName(superName), - (superclassSelections[superName]?.url ?? "") + "#data", - ), - ), + superclassSelections.keys.map( + (superName) => refer( + builtClassName(superName), + (superclassSelections[superName]?.url ?? "") + "#data", + ), + ), ) ..methods.addAll([ ...fieldGetters, @@ -56,7 +51,6 @@ List buildInlineFragmentClasses({ ..._inlineFragmentRootSerializationMethods( name: builtClassName(name), inlineFragments: inlineFragments, - dataClassAliasMap: dataClassAliasMap, ), ]), ), @@ -71,7 +65,6 @@ List buildInlineFragmentClasses({ fragmentMap, ), fragmentMap: fragmentMap, - dataClassAliasMap: dataClassAliasMap, schemaSource: schemaSource, type: type, typeOverrides: typeOverrides, @@ -84,46 +77,33 @@ List buildInlineFragmentClasses({ /// TODO: Handle inline fragments without a type condition /// https://spec.graphql.org/June2018/#sec-Inline-Fragments - ...inlineFragments.where((frag) { - if (frag.typeCondition == null) { - return false; - } - final typeName = - builtClassName("${name}__as${frag.typeCondition!.on.name.value}"); - if (dataClassAliasMap.containsKey(typeName)) { - // print("alias $typeName => ${dataClassAliasMap[typeName]!.symbol}"); - return false; - } - return true; - }).expand( - (inlineFragment) => buildSelectionSetDataClasses( - name: "${name}__as${inlineFragment.typeCondition!.on.name.value}", - selections: mergeSelections( - [ - ...selections.whereType(), - ...selections.whereType(), - ...inlineFragment.selectionSet.selections, - ], - fragmentMap, - ), - fragmentMap: fragmentMap, - dataClassAliasMap: dataClassAliasMap, - schemaSource: schemaSource, - type: inlineFragment.typeCondition!.on.name.value, - typeOverrides: typeOverrides, - superclassSelections: { - name: SourceSelections(url: null, selections: selections) - }, - built: built, - whenExtensionConfig: whenExtensionConfig), - ), + ...inlineFragments.where((frag) => frag.typeCondition != null).expand( + (inlineFragment) => buildSelectionSetDataClasses( + name: "${name}__as${inlineFragment.typeCondition!.on.name.value}", + selections: mergeSelections( + [ + ...selections.whereType(), + ...selections.whereType(), + ...inlineFragment.selectionSet.selections, + ], + fragmentMap, + ), + fragmentMap: fragmentMap, + schemaSource: schemaSource, + type: inlineFragment.typeCondition!.on.name.value, + typeOverrides: typeOverrides, + superclassSelections: { + name: SourceSelections(url: null, selections: selections) + }, + built: built, + whenExtensionConfig: whenExtensionConfig), + ), ]; } List _inlineFragmentRootSerializationMethods({ required String name, required List inlineFragments, - required Map dataClassAliasMap, }) => [ buildSerializerGetter(name).rebuild( @@ -141,11 +121,9 @@ List _inlineFragmentRootSerializationMethods({ { for (final v in inlineFragments .where((frag) => frag.typeCondition != null)) - "${v.typeCondition!.on.name.value}": dataClassAliasMap[ - "${name}__as${v.typeCondition!.on.name.value}"] ?? - refer( - "${name}__as${v.typeCondition!.on.name.value}", - ) + "${v.typeCondition!.on.name.value}": refer( + "${name}__as${v.typeCondition!.on.name.value}", + ) }, ), ]).code, diff --git a/codegen/gql_code_builder/lib/src/operation/data.dart b/codegen/gql_code_builder/lib/src/operation/data.dart index e8fea5ab..490ccf53 100644 --- a/codegen/gql_code_builder/lib/src/operation/data.dart +++ b/codegen/gql_code_builder/lib/src/operation/data.dart @@ -1,5 +1,4 @@ import "package:code_builder/code_builder.dart"; -import "package:collection/collection.dart"; import "package:gql/ast.dart"; import "package:gql_code_builder/src/config/when_extension_config.dart"; @@ -14,13 +13,12 @@ List buildOperationDataClasses( SourceNode schemaSource, Map typeOverrides, InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig, - Map fragmentMap, - Map dataClassAliasMap, ) { if (op.name == null) { throw Exception("Operations must be named"); } + final fragmentMap = _fragmentMap(docSource); return buildSelectionSetDataClasses( name: "${op.name!.value}Data", selections: mergeSelections( @@ -34,7 +32,6 @@ List buildOperationDataClasses( ), typeOverrides: typeOverrides, fragmentMap: fragmentMap, - dataClassAliasMap: dataClassAliasMap, superclassSelections: {}, whenExtensionConfig: whenExtensionConfig, ); @@ -46,9 +43,8 @@ List buildFragmentDataClasses( SourceNode schemaSource, Map typeOverrides, InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig, - Map fragmentMap, - Map dataClassAliasMap, ) { + final fragmentMap = _fragmentMap(docSource); final selections = mergeSelections( frag.selectionSet.selections, fragmentMap, @@ -62,7 +58,6 @@ List buildFragmentDataClasses( type: frag.typeCondition.on.name.value, typeOverrides: typeOverrides, fragmentMap: fragmentMap, - dataClassAliasMap: dataClassAliasMap, superclassSelections: {}, built: false, whenExtensionConfig: whenExtensionConfig, @@ -75,7 +70,6 @@ List buildFragmentDataClasses( type: frag.typeCondition.on.name.value, typeOverrides: typeOverrides, fragmentMap: fragmentMap, - dataClassAliasMap: dataClassAliasMap, superclassSelections: { frag.name.value: SourceSelections( url: docSource.url, @@ -104,6 +98,16 @@ String _operationType( .value; } +Map _fragmentMap(SourceNode source) => { + for (final def + in source.document.definitions.whereType()) + def.name.value: SourceSelections( + url: source.url, + selections: def.selectionSet.selections, + ), + for (final import in source.imports) ..._fragmentMap(import) + }; + /// Builds one or more data classes, with properties based on [selections]. /// /// For each selection that is a field with nested selections, a descendent @@ -120,7 +124,6 @@ List buildSelectionSetDataClasses({ required String type, required Map typeOverrides, required Map fragmentMap, - required Map dataClassAliasMap, required Map superclassSelections, bool built = true, required InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig, @@ -159,8 +162,6 @@ List buildSelectionSetDataClasses({ typeNode: typeNode, schemaSource: schemaSource, typeOverrides: typeOverrides, - typeRefAlias: - dataClassAliasMap[builtClassName("${name}_${nameNode.value}")], typeRefPrefix: node.selectionSet != null ? builtClassName(name) : null, built: built, isOverride: superclassSelectionNodes.contains(node), @@ -180,27 +181,23 @@ List buildSelectionSetDataClasses({ type: type, typeOverrides: typeOverrides, fragmentMap: fragmentMap, - dataClassAliasMap: dataClassAliasMap, superclassSelections: superclassSelections, inlineFragments: inlineFragments, built: built, whenExtensionConfig: whenExtensionConfig, ) - else if (!built && dataClassAliasMap[name] == null) + else if (!built) Class( (b) => b ..abstract = true ..name = builtClassName(name) ..implements.addAll( - superclassSelections.keys - .where((superName) => - !dataClassAliasMap.containsKey(builtClassName(superName))) - .map( - (superName) => refer( - builtClassName(superName), - (superclassSelections[superName]?.url ?? "") + "#data", - ), - ), + superclassSelections.keys.map( + (superName) => refer( + builtClassName(superName), + (superclassSelections[superName]?.url ?? "") + "#data", + ), + ), ) ..methods.addAll([ ...fieldGetters, @@ -220,23 +217,18 @@ List buildSelectionSetDataClasses({ "G__typename": literalString(type), }, superclassSelections: superclassSelections, - dataClassAliasMap: dataClassAliasMap, ), // Build classes for each field that includes selections ...selections .whereType() .where( - (field) => - field.selectionSet != null && - !dataClassAliasMap.containsKey(builtClassName( - "${name}_${field.alias?.value ?? field.name.value}")), + (field) => field.selectionSet != null, ) .expand( (field) => buildSelectionSetDataClasses( name: "${name}_${field.alias?.value ?? field.name.value}", selections: field.selectionSet!.selections, fragmentMap: fragmentMap, - dataClassAliasMap: dataClassAliasMap, schemaSource: schemaSource, type: unwrapTypeNode( _getFieldTypeNode( @@ -259,55 +251,6 @@ List buildSelectionSetDataClasses({ ]; } -/// Shrink merged fields nodes based on FragmentMap -List shrinkSelections( - List selections, - Map fragmentMap, -) { - final unmerged = [...selections]; - - for (final selection in selections) { - if (selection is FieldNode && selection.selectionSet != null) { - final index = unmerged.indexOf(selection); - unmerged[index] = FieldNode( - name: selection.name, - alias: selection.alias, - selectionSet: SelectionSetNode( - selections: - shrinkSelections(selection.selectionSet!.selections, fragmentMap), - ), - ); - } else if (selection is InlineFragmentNode && - selection.typeCondition != null) { - /// TODO: Handle inline fragments without a type condition - final index = unmerged.indexOf(selection); - unmerged[index] = InlineFragmentNode( - typeCondition: selection.typeCondition, - directives: selection.directives, - selectionSet: SelectionSetNode( - selections: - shrinkSelections(selection.selectionSet.selections, fragmentMap), - ), - ); - } - } - - for (final node in unmerged.whereType().toList()) { - final fragment = fragmentMap[node.name.value]!; - final spreadIndex = unmerged.indexOf(node); - final duplicateIndexList = []; - unmerged.forEachIndexed((selectionIndex, selection) { - if (selectionIndex > spreadIndex && - fragment.selections.any((s) => s.hashCode == selection.hashCode)) { - duplicateIndexList.add(selectionIndex); - } - }); - duplicateIndexList.reversed.forEach(unmerged.removeAt); - } - - return unmerged; -} - /// Deeply merges field nodes List mergeSelections( List selections, @@ -339,29 +282,6 @@ List mergeSelections( fragmentMap, ))); } - } else if (selection is InlineFragmentNode && - selection.typeCondition != null) { - /// TODO: Handle inline fragments without a type condition - final key = selection.typeCondition!.on.name.value; - if (selectionMap.containsKey(key)) { - selectionMap[key] = InlineFragmentNode( - typeCondition: selection.typeCondition, - directives: selection.directives, - selectionSet: SelectionSetNode( - selections: mergeSelections( - [ - ...(selectionMap[key] as InlineFragmentNode) - .selectionSet - .selections, - ...selection.selectionSet.selections, - ], - fragmentMap, - ), - ), - ); - } else { - selectionMap[key] = selection; - } } else { selectionMap[selection.hashCode.toString()] = selection; } diff --git a/codegen/gql_code_builder/lib/src/when_extension.dart b/codegen/gql_code_builder/lib/src/when_extension.dart index 197bcab4..52987e54 100644 --- a/codegen/gql_code_builder/lib/src/when_extension.dart +++ b/codegen/gql_code_builder/lib/src/when_extension.dart @@ -39,8 +39,7 @@ Code _caseStatement(InlineFragmentNode inlineFragment) => Extension? inlineFragmentWhenExtension( {required String baseTypeName, required List inlineFragments, - required InlineFragmentSpreadWhenExtensionConfig config, - required Map dataClassAliasMap}) { + required InlineFragmentSpreadWhenExtensionConfig config}) { final inlineFragmentsWithTypConditions = inlineFragments .where((inlineFragment) => inlineFragment.typeCondition != null) .toList(); @@ -55,11 +54,8 @@ Extension? inlineFragmentWhenExtension( /// returns the name of the concrete built class for the inlineFragment /// so we can refer to it in the generated code - String getGeneratedTypeName(InlineFragmentNode node) { - final typeName = builtClassName( - "${baseTypeName}__as${node.typeCondition!.on.name.value}"); - return dataClassAliasMap[typeName]?.symbol ?? typeName; - } + String getGeneratedTypeName(InlineFragmentNode node) => + builtClassName("${baseTypeName}__as${node.typeCondition!.on.name.value}"); /// a pool of parameter names which have already been used /// so we can avoid name clashes From 03e98be27448ad28ed0c239670f232146c24d6c2 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 7 Jan 2024 04:52:47 +0000 Subject: [PATCH 02/12] simpler version of reuse fragments with less scope --- .../alias_var_fragment.data.gql.dart | 107 +- .../alias_var_fragment.data.gql.g.dart | 585 +------- .../fragment_with_scalar_var.ast.gql.dart | 44 + .../fragment_with_scalar_var.data.gql.dart | 133 +- .../fragment_with_scalar_var.data.gql.g.dart | 409 +++-- .../fragment_with_scalar_var.var.gql.dart | 24 + .../fragment_with_scalar_var.var.gql.g.dart | 88 ++ .../hero_with_fragments.data.gql.dart | 212 +-- .../hero_with_fragments.data.gql.g.dart | 1310 ++--------------- .../fragment_with_scalar_var.graphql | 7 + .../__generated__/serializers.gql.dart | 34 +- .../__generated__/serializers.gql.g.dart | 29 +- codegen/end_to_end_test/pubspec.yaml | 39 + 13 files changed, 641 insertions(+), 2380 deletions(-) diff --git a/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.dart b/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.dart index 4a86762c..5e78a0dd 100644 --- a/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.dart +++ b/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.dart @@ -2,7 +2,6 @@ // 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/graphql/__generated__/serializers.gql.dart' @@ -21,7 +20,7 @@ abstract class GPostsData implements Built { @BuiltValueField(wireName: '__typename') String get G__typename; - BuiltList? get posts; + GPostFragmentData get posts; static Serializer get serializer => _$gPostsDataSerializer; Map toJson() => (_i1.serializers.serializeWith( @@ -36,110 +35,6 @@ abstract class GPostsData implements Built { ); } -abstract class GPostsData_posts - implements Built, GPostFragment { - GPostsData_posts._(); - - factory GPostsData_posts([void 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( - [void 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( - [void 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; diff --git a/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.g.dart b/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.g.dart index bdd60526..cb69b019 100644 --- a/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.g.dart +++ b/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.g.dart @@ -7,13 +7,6 @@ part of 'alias_var_fragment.data.gql.dart'; // ************************************************************************** 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 @@ -35,16 +28,11 @@ class _$GPostsDataSerializer implements StructuredSerializer { '__typename', serializers.serialize(object.G__typename, specifiedType: const FullType(String)), + 'posts', + serializers.serialize(object.posts, + specifiedType: const FullType(GPostFragmentData)), ]; - 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; } @@ -65,187 +53,8 @@ class _$GPostsDataSerializer implements StructuredSerializer { 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; + specifiedType: const FullType(GPostFragmentData))! + as GPostFragmentData); break; } } @@ -436,14 +245,15 @@ class _$GPostsData extends GPostsData { @override final String G__typename; @override - final BuiltList? posts; + final GPostFragmentData posts; factory _$GPostsData([void Function(GPostsDataBuilder)? updates]) => (new GPostsDataBuilder()..update(updates))._build(); - _$GPostsData._({required this.G__typename, this.posts}) : super._() { + _$GPostsData._({required this.G__typename, required this.posts}) : super._() { BuiltValueNullFieldError.checkNotNull( G__typename, r'GPostsData', 'G__typename'); + BuiltValueNullFieldError.checkNotNull(posts, r'GPostsData', 'posts'); } @override @@ -486,10 +296,10 @@ class GPostsDataBuilder implements Builder { 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; + GPostFragmentDataBuilder? _posts; + GPostFragmentDataBuilder get posts => + _$this._posts ??= new GPostFragmentDataBuilder(); + set posts(GPostFragmentDataBuilder? posts) => _$this._posts = posts; GPostsDataBuilder() { GPostsData._initializeBuilder(this); @@ -499,7 +309,7 @@ class GPostsDataBuilder implements Builder { final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; - _posts = $v.posts?.toBuilder(); + _posts = $v.posts.toBuilder(); _$v = null; } return this; @@ -526,12 +336,12 @@ class GPostsDataBuilder implements Builder { new _$GPostsData._( G__typename: BuiltValueNullFieldError.checkNotNull( G__typename, r'GPostsData', 'G__typename'), - posts: _posts?.build()); + posts: posts.build()); } catch (_) { late String _$failedField; try { _$failedField = 'posts'; - _posts?.build(); + posts.build(); } catch (e) { throw new BuiltValueNestedFieldError( r'GPostsData', _$failedField, e.toString()); @@ -543,369 +353,6 @@ class GPostsDataBuilder implements Builder { } } -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; diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.ast.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.ast.gql.dart index 2400af93..b99b7a03 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.ast.gql.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.ast.gql.dart @@ -47,6 +47,49 @@ const PostFragmentForUser1 = _i1.FragmentDefinitionNode( ), ]), ); +const PostFragmentForUser2 = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'PostFragmentForUser2'), + 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'), @@ -84,5 +127,6 @@ const PostsWithFixedVariable = _i1.OperationDefinitionNode( ); const document = _i1.DocumentNode(definitions: [ PostFragmentForUser1, + PostFragmentForUser2, PostsWithFixedVariable, ]); diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.dart index 18474aed..a6af8498 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.dart @@ -2,7 +2,6 @@ // 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/graphql/__generated__/serializers.gql.dart' @@ -24,7 +23,7 @@ abstract class GPostsWithFixedVariableData @BuiltValueField(wireName: '__typename') String get G__typename; - BuiltList? get posts; + GPostFragmentForUser2Data get posts; static Serializer get serializer => _$gPostsWithFixedVariableDataSerializer; @@ -40,18 +39,30 @@ abstract class GPostsWithFixedVariableData ); } -abstract class GPostsWithFixedVariableData_posts +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, + Built, GPostFragmentForUser1 { - GPostsWithFixedVariableData_posts._(); + GPostFragmentForUser1Data._(); - factory GPostsWithFixedVariableData_posts( - [void Function(GPostsWithFixedVariableData_postsBuilder b) updates]) = - _$GPostsWithFixedVariableData_posts; + factory GPostFragmentForUser1Data( + [void Function(GPostFragmentForUser1DataBuilder b) updates]) = + _$GPostFragmentForUser1Data; - static void _initializeBuilder(GPostsWithFixedVariableData_postsBuilder b) => + static void _initializeBuilder(GPostFragmentForUser1DataBuilder b) => b..G__typename = 'Post'; @override @@ -60,37 +71,36 @@ abstract class GPostsWithFixedVariableData_posts @override String get id; @override - GPostsWithFixedVariableData_posts_favoritedUsers? get favoritedUsers; - static Serializer get serializer => - _$gPostsWithFixedVariableDataPostsSerializer; + GPostFragmentForUser1Data_favoritedUsers? get favoritedUsers; + static Serializer get serializer => + _$gPostFragmentForUser1DataSerializer; @override Map toJson() => (_i1.serializers.serializeWith( - GPostsWithFixedVariableData_posts.serializer, + GPostFragmentForUser1Data.serializer, this, ) as Map); - static GPostsWithFixedVariableData_posts? fromJson( - Map json) => + static GPostFragmentForUser1Data? fromJson(Map json) => _i1.serializers.deserializeWith( - GPostsWithFixedVariableData_posts.serializer, + GPostFragmentForUser1Data.serializer, json, ); } -abstract class GPostsWithFixedVariableData_posts_favoritedUsers +abstract class GPostFragmentForUser1Data_favoritedUsers implements - Built, + Built, GPostFragmentForUser1_favoritedUsers { - GPostsWithFixedVariableData_posts_favoritedUsers._(); + GPostFragmentForUser1Data_favoritedUsers._(); - factory GPostsWithFixedVariableData_posts_favoritedUsers( - [void Function(GPostsWithFixedVariableData_posts_favoritedUsersBuilder b) - updates]) = _$GPostsWithFixedVariableData_posts_favoritedUsers; + factory GPostFragmentForUser1Data_favoritedUsers( + [void Function(GPostFragmentForUser1Data_favoritedUsersBuilder b) + updates]) = _$GPostFragmentForUser1Data_favoritedUsers; static void _initializeBuilder( - GPostsWithFixedVariableData_posts_favoritedUsersBuilder b) => + GPostFragmentForUser1Data_favoritedUsersBuilder b) => b..G__typename = 'PostLikes'; @override @@ -98,48 +108,47 @@ abstract class GPostsWithFixedVariableData_posts_favoritedUsers String get G__typename; @override int get totalCount; - static Serializer - get serializer => - _$gPostsWithFixedVariableDataPostsFavoritedUsersSerializer; + static Serializer get serializer => + _$gPostFragmentForUser1DataFavoritedUsersSerializer; @override Map toJson() => (_i1.serializers.serializeWith( - GPostsWithFixedVariableData_posts_favoritedUsers.serializer, + GPostFragmentForUser1Data_favoritedUsers.serializer, this, ) as Map); - static GPostsWithFixedVariableData_posts_favoritedUsers? fromJson( + static GPostFragmentForUser1Data_favoritedUsers? fromJson( Map json) => _i1.serializers.deserializeWith( - GPostsWithFixedVariableData_posts_favoritedUsers.serializer, + GPostFragmentForUser1Data_favoritedUsers.serializer, json, ); } -abstract class GPostFragmentForUser1 { +abstract class GPostFragmentForUser2 { String get G__typename; String get id; - GPostFragmentForUser1_favoritedUsers? get favoritedUsers; + GPostFragmentForUser2_favoritedUsers? get favoritedUsers; Map toJson(); } -abstract class GPostFragmentForUser1_favoritedUsers { +abstract class GPostFragmentForUser2_favoritedUsers { String get G__typename; int get totalCount; Map toJson(); } -abstract class GPostFragmentForUser1Data +abstract class GPostFragmentForUser2Data implements - Built, - GPostFragmentForUser1 { - GPostFragmentForUser1Data._(); + Built, + GPostFragmentForUser2 { + GPostFragmentForUser2Data._(); - factory GPostFragmentForUser1Data( - [void Function(GPostFragmentForUser1DataBuilder b) updates]) = - _$GPostFragmentForUser1Data; + factory GPostFragmentForUser2Data( + [void Function(GPostFragmentForUser2DataBuilder b) updates]) = + _$GPostFragmentForUser2Data; - static void _initializeBuilder(GPostFragmentForUser1DataBuilder b) => + static void _initializeBuilder(GPostFragmentForUser2DataBuilder b) => b..G__typename = 'Post'; @override @@ -148,36 +157,36 @@ abstract class GPostFragmentForUser1Data @override String get id; @override - GPostFragmentForUser1Data_favoritedUsers? get favoritedUsers; - static Serializer get serializer => - _$gPostFragmentForUser1DataSerializer; + GPostFragmentForUser2Data_favoritedUsers? get favoritedUsers; + static Serializer get serializer => + _$gPostFragmentForUser2DataSerializer; @override Map toJson() => (_i1.serializers.serializeWith( - GPostFragmentForUser1Data.serializer, + GPostFragmentForUser2Data.serializer, this, ) as Map); - static GPostFragmentForUser1Data? fromJson(Map json) => + static GPostFragmentForUser2Data? fromJson(Map json) => _i1.serializers.deserializeWith( - GPostFragmentForUser1Data.serializer, + GPostFragmentForUser2Data.serializer, json, ); } -abstract class GPostFragmentForUser1Data_favoritedUsers +abstract class GPostFragmentForUser2Data_favoritedUsers implements - Built, - GPostFragmentForUser1_favoritedUsers { - GPostFragmentForUser1Data_favoritedUsers._(); + Built, + GPostFragmentForUser2_favoritedUsers { + GPostFragmentForUser2Data_favoritedUsers._(); - factory GPostFragmentForUser1Data_favoritedUsers( - [void Function(GPostFragmentForUser1Data_favoritedUsersBuilder b) - updates]) = _$GPostFragmentForUser1Data_favoritedUsers; + factory GPostFragmentForUser2Data_favoritedUsers( + [void Function(GPostFragmentForUser2Data_favoritedUsersBuilder b) + updates]) = _$GPostFragmentForUser2Data_favoritedUsers; static void _initializeBuilder( - GPostFragmentForUser1Data_favoritedUsersBuilder b) => + GPostFragmentForUser2Data_favoritedUsersBuilder b) => b..G__typename = 'PostLikes'; @override @@ -185,19 +194,19 @@ abstract class GPostFragmentForUser1Data_favoritedUsers String get G__typename; @override int get totalCount; - static Serializer get serializer => - _$gPostFragmentForUser1DataFavoritedUsersSerializer; + static Serializer get serializer => + _$gPostFragmentForUser2DataFavoritedUsersSerializer; @override Map toJson() => (_i1.serializers.serializeWith( - GPostFragmentForUser1Data_favoritedUsers.serializer, + GPostFragmentForUser2Data_favoritedUsers.serializer, this, ) as Map); - static GPostFragmentForUser1Data_favoritedUsers? fromJson( + static GPostFragmentForUser2Data_favoritedUsers? fromJson( Map json) => _i1.serializers.deserializeWith( - GPostFragmentForUser1Data_favoritedUsers.serializer, + GPostFragmentForUser2Data_favoritedUsers.serializer, json, ); } diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.g.dart index e5559c99..91dcdf26 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.g.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.g.dart @@ -9,17 +9,16 @@ part of 'fragment_with_scalar_var.data.gql.dart'; Serializer _$gPostsWithFixedVariableDataSerializer = new _$GPostsWithFixedVariableDataSerializer(); -Serializer - _$gPostsWithFixedVariableDataPostsSerializer = - new _$GPostsWithFixedVariableData_postsSerializer(); -Serializer - _$gPostsWithFixedVariableDataPostsFavoritedUsersSerializer = - new _$GPostsWithFixedVariableData_posts_favoritedUsersSerializer(); Serializer _$gPostFragmentForUser1DataSerializer = new _$GPostFragmentForUser1DataSerializer(); Serializer _$gPostFragmentForUser1DataFavoritedUsersSerializer = new _$GPostFragmentForUser1Data_favoritedUsersSerializer(); +Serializer _$gPostFragmentForUser2DataSerializer = + new _$GPostFragmentForUser2DataSerializer(); +Serializer + _$gPostFragmentForUser2DataFavoritedUsersSerializer = + new _$GPostFragmentForUser2Data_favoritedUsersSerializer(); class _$GPostsWithFixedVariableDataSerializer implements StructuredSerializer { @@ -39,17 +38,11 @@ class _$GPostsWithFixedVariableDataSerializer '__typename', serializers.serialize(object.G__typename, specifiedType: const FullType(String)), + 'posts', + serializers.serialize(object.posts, + specifiedType: const FullType(GPostFragmentForUser2Data)), ]; - 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; } @@ -71,9 +64,8 @@ class _$GPostsWithFixedVariableDataSerializer break; case 'posts': result.posts.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltList, const [ - const FullType.nullable(GPostsWithFixedVariableData_posts) - ]))! as BuiltList); + specifiedType: const FullType(GPostFragmentForUser2Data))! + as GPostFragmentForUser2Data); break; } } @@ -82,19 +74,19 @@ class _$GPostsWithFixedVariableDataSerializer } } -class _$GPostsWithFixedVariableData_postsSerializer - implements StructuredSerializer { +class _$GPostFragmentForUser1DataSerializer + implements StructuredSerializer { @override final Iterable types = const [ - GPostsWithFixedVariableData_posts, - _$GPostsWithFixedVariableData_posts + GPostFragmentForUser1Data, + _$GPostFragmentForUser1Data ]; @override - final String wireName = 'GPostsWithFixedVariableData_posts'; + final String wireName = 'GPostFragmentForUser1Data'; @override Iterable serialize( - Serializers serializers, GPostsWithFixedVariableData_posts object, + Serializers serializers, GPostFragmentForUser1Data object, {FullType specifiedType = FullType.unspecified}) { final result = [ '__typename', @@ -109,17 +101,17 @@ class _$GPostsWithFixedVariableData_postsSerializer result ..add('favoritedUsers') ..add(serializers.serialize(value, - specifiedType: const FullType( - GPostsWithFixedVariableData_posts_favoritedUsers))); + specifiedType: + const FullType(GPostFragmentForUser1Data_favoritedUsers))); } return result; } @override - GPostsWithFixedVariableData_posts deserialize( + GPostFragmentForUser1Data deserialize( Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { - final result = new GPostsWithFixedVariableData_postsBuilder(); + final result = new GPostFragmentForUser1DataBuilder(); final iterator = serialized.iterator; while (iterator.moveNext()) { @@ -137,9 +129,9 @@ class _$GPostsWithFixedVariableData_postsSerializer break; case 'favoritedUsers': result.favoritedUsers.replace(serializers.deserialize(value, - specifiedType: const FullType( - GPostsWithFixedVariableData_posts_favoritedUsers))! - as GPostsWithFixedVariableData_posts_favoritedUsers); + specifiedType: + const FullType(GPostFragmentForUser1Data_favoritedUsers))! + as GPostFragmentForUser1Data_favoritedUsers); break; } } @@ -148,20 +140,19 @@ class _$GPostsWithFixedVariableData_postsSerializer } } -class _$GPostsWithFixedVariableData_posts_favoritedUsersSerializer - implements - StructuredSerializer { +class _$GPostFragmentForUser1Data_favoritedUsersSerializer + implements StructuredSerializer { @override final Iterable types = const [ - GPostsWithFixedVariableData_posts_favoritedUsers, - _$GPostsWithFixedVariableData_posts_favoritedUsers + GPostFragmentForUser1Data_favoritedUsers, + _$GPostFragmentForUser1Data_favoritedUsers ]; @override - final String wireName = 'GPostsWithFixedVariableData_posts_favoritedUsers'; + final String wireName = 'GPostFragmentForUser1Data_favoritedUsers'; @override - Iterable serialize(Serializers serializers, - GPostsWithFixedVariableData_posts_favoritedUsers object, + Iterable serialize( + Serializers serializers, GPostFragmentForUser1Data_favoritedUsers object, {FullType specifiedType = FullType.unspecified}) { final result = [ '__typename', @@ -176,11 +167,10 @@ class _$GPostsWithFixedVariableData_posts_favoritedUsersSerializer } @override - GPostsWithFixedVariableData_posts_favoritedUsers deserialize( + GPostFragmentForUser1Data_favoritedUsers deserialize( Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { - final result = - new GPostsWithFixedVariableData_posts_favoritedUsersBuilder(); + final result = new GPostFragmentForUser1Data_favoritedUsersBuilder(); final iterator = serialized.iterator; while (iterator.moveNext()) { @@ -203,19 +193,19 @@ class _$GPostsWithFixedVariableData_posts_favoritedUsersSerializer } } -class _$GPostFragmentForUser1DataSerializer - implements StructuredSerializer { +class _$GPostFragmentForUser2DataSerializer + implements StructuredSerializer { @override final Iterable types = const [ - GPostFragmentForUser1Data, - _$GPostFragmentForUser1Data + GPostFragmentForUser2Data, + _$GPostFragmentForUser2Data ]; @override - final String wireName = 'GPostFragmentForUser1Data'; + final String wireName = 'GPostFragmentForUser2Data'; @override Iterable serialize( - Serializers serializers, GPostFragmentForUser1Data object, + Serializers serializers, GPostFragmentForUser2Data object, {FullType specifiedType = FullType.unspecified}) { final result = [ '__typename', @@ -231,16 +221,16 @@ class _$GPostFragmentForUser1DataSerializer ..add('favoritedUsers') ..add(serializers.serialize(value, specifiedType: - const FullType(GPostFragmentForUser1Data_favoritedUsers))); + const FullType(GPostFragmentForUser2Data_favoritedUsers))); } return result; } @override - GPostFragmentForUser1Data deserialize( + GPostFragmentForUser2Data deserialize( Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { - final result = new GPostFragmentForUser1DataBuilder(); + final result = new GPostFragmentForUser2DataBuilder(); final iterator = serialized.iterator; while (iterator.moveNext()) { @@ -259,8 +249,8 @@ class _$GPostFragmentForUser1DataSerializer case 'favoritedUsers': result.favoritedUsers.replace(serializers.deserialize(value, specifiedType: - const FullType(GPostFragmentForUser1Data_favoritedUsers))! - as GPostFragmentForUser1Data_favoritedUsers); + const FullType(GPostFragmentForUser2Data_favoritedUsers))! + as GPostFragmentForUser2Data_favoritedUsers); break; } } @@ -269,19 +259,19 @@ class _$GPostFragmentForUser1DataSerializer } } -class _$GPostFragmentForUser1Data_favoritedUsersSerializer - implements StructuredSerializer { +class _$GPostFragmentForUser2Data_favoritedUsersSerializer + implements StructuredSerializer { @override final Iterable types = const [ - GPostFragmentForUser1Data_favoritedUsers, - _$GPostFragmentForUser1Data_favoritedUsers + GPostFragmentForUser2Data_favoritedUsers, + _$GPostFragmentForUser2Data_favoritedUsers ]; @override - final String wireName = 'GPostFragmentForUser1Data_favoritedUsers'; + final String wireName = 'GPostFragmentForUser2Data_favoritedUsers'; @override Iterable serialize( - Serializers serializers, GPostFragmentForUser1Data_favoritedUsers object, + Serializers serializers, GPostFragmentForUser2Data_favoritedUsers object, {FullType specifiedType = FullType.unspecified}) { final result = [ '__typename', @@ -296,10 +286,10 @@ class _$GPostFragmentForUser1Data_favoritedUsersSerializer } @override - GPostFragmentForUser1Data_favoritedUsers deserialize( + GPostFragmentForUser2Data_favoritedUsers deserialize( Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { - final result = new GPostFragmentForUser1Data_favoritedUsersBuilder(); + final result = new GPostFragmentForUser2Data_favoritedUsersBuilder(); final iterator = serialized.iterator; while (iterator.moveNext()) { @@ -326,16 +316,19 @@ class _$GPostsWithFixedVariableData extends GPostsWithFixedVariableData { @override final String G__typename; @override - final BuiltList? posts; + final GPostFragmentForUser2Data posts; factory _$GPostsWithFixedVariableData( [void Function(GPostsWithFixedVariableDataBuilder)? updates]) => (new GPostsWithFixedVariableDataBuilder()..update(updates))._build(); - _$GPostsWithFixedVariableData._({required this.G__typename, this.posts}) + _$GPostsWithFixedVariableData._( + {required this.G__typename, required this.posts}) : super._() { BuiltValueNullFieldError.checkNotNull( G__typename, r'GPostsWithFixedVariableData', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + posts, r'GPostsWithFixedVariableData', 'posts'); } @override @@ -383,11 +376,10 @@ class GPostsWithFixedVariableDataBuilder 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; + GPostFragmentForUser2DataBuilder? _posts; + GPostFragmentForUser2DataBuilder get posts => + _$this._posts ??= new GPostFragmentForUser2DataBuilder(); + set posts(GPostFragmentForUser2DataBuilder? posts) => _$this._posts = posts; GPostsWithFixedVariableDataBuilder() { GPostsWithFixedVariableData._initializeBuilder(this); @@ -397,7 +389,7 @@ class GPostsWithFixedVariableDataBuilder final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; - _posts = $v.posts?.toBuilder(); + _posts = $v.posts.toBuilder(); _$v = null; } return this; @@ -424,12 +416,12 @@ class GPostsWithFixedVariableDataBuilder new _$GPostsWithFixedVariableData._( G__typename: BuiltValueNullFieldError.checkNotNull( G__typename, r'GPostsWithFixedVariableData', 'G__typename'), - posts: _posts?.build()); + posts: posts.build()); } catch (_) { late String _$failedField; try { _$failedField = 'posts'; - _posts?.build(); + posts.build(); } catch (e) { throw new BuiltValueNestedFieldError( r'GPostsWithFixedVariableData', _$failedField, e.toString()); @@ -441,42 +433,40 @@ class GPostsWithFixedVariableDataBuilder } } -class _$GPostsWithFixedVariableData_posts - extends GPostsWithFixedVariableData_posts { +class _$GPostFragmentForUser1Data extends GPostFragmentForUser1Data { @override final String G__typename; @override final String id; @override - final GPostsWithFixedVariableData_posts_favoritedUsers? favoritedUsers; + final GPostFragmentForUser1Data_favoritedUsers? favoritedUsers; - factory _$GPostsWithFixedVariableData_posts( - [void Function(GPostsWithFixedVariableData_postsBuilder)? updates]) => - (new GPostsWithFixedVariableData_postsBuilder()..update(updates)) - ._build(); + factory _$GPostFragmentForUser1Data( + [void Function(GPostFragmentForUser1DataBuilder)? updates]) => + (new GPostFragmentForUser1DataBuilder()..update(updates))._build(); - _$GPostsWithFixedVariableData_posts._( + _$GPostFragmentForUser1Data._( {required this.G__typename, required this.id, this.favoritedUsers}) : super._() { BuiltValueNullFieldError.checkNotNull( - G__typename, r'GPostsWithFixedVariableData_posts', 'G__typename'); + G__typename, r'GPostFragmentForUser1Data', 'G__typename'); BuiltValueNullFieldError.checkNotNull( - id, r'GPostsWithFixedVariableData_posts', 'id'); + id, r'GPostFragmentForUser1Data', 'id'); } @override - GPostsWithFixedVariableData_posts rebuild( - void Function(GPostsWithFixedVariableData_postsBuilder) updates) => + GPostFragmentForUser1Data rebuild( + void Function(GPostFragmentForUser1DataBuilder) updates) => (toBuilder()..update(updates)).build(); @override - GPostsWithFixedVariableData_postsBuilder toBuilder() => - new GPostsWithFixedVariableData_postsBuilder()..replace(this); + GPostFragmentForUser1DataBuilder toBuilder() => + new GPostFragmentForUser1DataBuilder()..replace(this); @override bool operator ==(Object other) { if (identical(other, this)) return true; - return other is GPostsWithFixedVariableData_posts && + return other is GPostFragmentForUser1Data && G__typename == other.G__typename && id == other.id && favoritedUsers == other.favoritedUsers; @@ -494,7 +484,7 @@ class _$GPostsWithFixedVariableData_posts @override String toString() { - return (newBuiltValueToStringHelper(r'GPostsWithFixedVariableData_posts') + return (newBuiltValueToStringHelper(r'GPostFragmentForUser1Data') ..add('G__typename', G__typename) ..add('id', id) ..add('favoritedUsers', favoritedUsers)) @@ -502,11 +492,10 @@ class _$GPostsWithFixedVariableData_posts } } -class GPostsWithFixedVariableData_postsBuilder +class GPostFragmentForUser1DataBuilder implements - Builder { - _$GPostsWithFixedVariableData_posts? _$v; + Builder { + _$GPostFragmentForUser1Data? _$v; String? _G__typename; String? get G__typename => _$this._G__typename; @@ -516,20 +505,19 @@ class GPostsWithFixedVariableData_postsBuilder String? get id => _$this._id; set id(String? id) => _$this._id = id; - GPostsWithFixedVariableData_posts_favoritedUsersBuilder? _favoritedUsers; - GPostsWithFixedVariableData_posts_favoritedUsersBuilder get favoritedUsers => + GPostFragmentForUser1Data_favoritedUsersBuilder? _favoritedUsers; + GPostFragmentForUser1Data_favoritedUsersBuilder get favoritedUsers => _$this._favoritedUsers ??= - new GPostsWithFixedVariableData_posts_favoritedUsersBuilder(); + new GPostFragmentForUser1Data_favoritedUsersBuilder(); set favoritedUsers( - GPostsWithFixedVariableData_posts_favoritedUsersBuilder? - favoritedUsers) => + GPostFragmentForUser1Data_favoritedUsersBuilder? favoritedUsers) => _$this._favoritedUsers = favoritedUsers; - GPostsWithFixedVariableData_postsBuilder() { - GPostsWithFixedVariableData_posts._initializeBuilder(this); + GPostFragmentForUser1DataBuilder() { + GPostFragmentForUser1Data._initializeBuilder(this); } - GPostsWithFixedVariableData_postsBuilder get _$this { + GPostFragmentForUser1DataBuilder get _$this { final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; @@ -541,29 +529,28 @@ class GPostsWithFixedVariableData_postsBuilder } @override - void replace(GPostsWithFixedVariableData_posts other) { + void replace(GPostFragmentForUser1Data other) { ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$GPostsWithFixedVariableData_posts; + _$v = other as _$GPostFragmentForUser1Data; } @override - void update( - void Function(GPostsWithFixedVariableData_postsBuilder)? updates) { + void update(void Function(GPostFragmentForUser1DataBuilder)? updates) { if (updates != null) updates(this); } @override - GPostsWithFixedVariableData_posts build() => _build(); + GPostFragmentForUser1Data build() => _build(); - _$GPostsWithFixedVariableData_posts _build() { - _$GPostsWithFixedVariableData_posts _$result; + _$GPostFragmentForUser1Data _build() { + _$GPostFragmentForUser1Data _$result; try { _$result = _$v ?? - new _$GPostsWithFixedVariableData_posts._( - G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, - r'GPostsWithFixedVariableData_posts', 'G__typename'), + new _$GPostFragmentForUser1Data._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GPostFragmentForUser1Data', 'G__typename'), id: BuiltValueNullFieldError.checkNotNull( - id, r'GPostsWithFixedVariableData_posts', 'id'), + id, r'GPostFragmentForUser1Data', 'id'), favoritedUsers: _favoritedUsers?.build()); } catch (_) { late String _$failedField; @@ -572,7 +559,7 @@ class GPostsWithFixedVariableData_postsBuilder _favoritedUsers?.build(); } catch (e) { throw new BuiltValueNestedFieldError( - r'GPostsWithFixedVariableData_posts', _$failedField, e.toString()); + r'GPostFragmentForUser1Data', _$failedField, e.toString()); } rethrow; } @@ -581,45 +568,42 @@ class GPostsWithFixedVariableData_postsBuilder } } -class _$GPostsWithFixedVariableData_posts_favoritedUsers - extends GPostsWithFixedVariableData_posts_favoritedUsers { +class _$GPostFragmentForUser1Data_favoritedUsers + extends GPostFragmentForUser1Data_favoritedUsers { @override final String G__typename; @override final int totalCount; - factory _$GPostsWithFixedVariableData_posts_favoritedUsers( - [void Function( - GPostsWithFixedVariableData_posts_favoritedUsersBuilder)? + factory _$GPostFragmentForUser1Data_favoritedUsers( + [void Function(GPostFragmentForUser1Data_favoritedUsersBuilder)? updates]) => - (new GPostsWithFixedVariableData_posts_favoritedUsersBuilder() - ..update(updates)) + (new GPostFragmentForUser1Data_favoritedUsersBuilder()..update(updates)) ._build(); - _$GPostsWithFixedVariableData_posts_favoritedUsers._( + _$GPostFragmentForUser1Data_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'); + r'GPostFragmentForUser1Data_favoritedUsers', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + totalCount, r'GPostFragmentForUser1Data_favoritedUsers', 'totalCount'); } @override - GPostsWithFixedVariableData_posts_favoritedUsers rebuild( - void Function(GPostsWithFixedVariableData_posts_favoritedUsersBuilder) + GPostFragmentForUser1Data_favoritedUsers rebuild( + void Function(GPostFragmentForUser1Data_favoritedUsersBuilder) updates) => (toBuilder()..update(updates)).build(); @override - GPostsWithFixedVariableData_posts_favoritedUsersBuilder toBuilder() => - new GPostsWithFixedVariableData_posts_favoritedUsersBuilder() - ..replace(this); + GPostFragmentForUser1Data_favoritedUsersBuilder toBuilder() => + new GPostFragmentForUser1Data_favoritedUsersBuilder()..replace(this); @override bool operator ==(Object other) { if (identical(other, this)) return true; - return other is GPostsWithFixedVariableData_posts_favoritedUsers && + return other is GPostFragmentForUser1Data_favoritedUsers && G__typename == other.G__typename && totalCount == other.totalCount; } @@ -636,18 +620,18 @@ class _$GPostsWithFixedVariableData_posts_favoritedUsers @override String toString() { return (newBuiltValueToStringHelper( - r'GPostsWithFixedVariableData_posts_favoritedUsers') + r'GPostFragmentForUser1Data_favoritedUsers') ..add('G__typename', G__typename) ..add('totalCount', totalCount)) .toString(); } } -class GPostsWithFixedVariableData_posts_favoritedUsersBuilder +class GPostFragmentForUser1Data_favoritedUsersBuilder implements - Builder { - _$GPostsWithFixedVariableData_posts_favoritedUsers? _$v; + Builder { + _$GPostFragmentForUser1Data_favoritedUsers? _$v; String? _G__typename; String? get G__typename => _$this._G__typename; @@ -657,11 +641,11 @@ class GPostsWithFixedVariableData_posts_favoritedUsersBuilder int? get totalCount => _$this._totalCount; set totalCount(int? totalCount) => _$this._totalCount = totalCount; - GPostsWithFixedVariableData_posts_favoritedUsersBuilder() { - GPostsWithFixedVariableData_posts_favoritedUsers._initializeBuilder(this); + GPostFragmentForUser1Data_favoritedUsersBuilder() { + GPostFragmentForUser1Data_favoritedUsers._initializeBuilder(this); } - GPostsWithFixedVariableData_posts_favoritedUsersBuilder get _$this { + GPostFragmentForUser1Data_favoritedUsersBuilder get _$this { final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; @@ -672,71 +656,66 @@ class GPostsWithFixedVariableData_posts_favoritedUsersBuilder } @override - void replace(GPostsWithFixedVariableData_posts_favoritedUsers other) { + void replace(GPostFragmentForUser1Data_favoritedUsers other) { ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$GPostsWithFixedVariableData_posts_favoritedUsers; + _$v = other as _$GPostFragmentForUser1Data_favoritedUsers; } @override void update( - void Function(GPostsWithFixedVariableData_posts_favoritedUsersBuilder)? - updates) { + void Function(GPostFragmentForUser1Data_favoritedUsersBuilder)? updates) { if (updates != null) updates(this); } @override - GPostsWithFixedVariableData_posts_favoritedUsers build() => _build(); + GPostFragmentForUser1Data_favoritedUsers build() => _build(); - _$GPostsWithFixedVariableData_posts_favoritedUsers _build() { + _$GPostFragmentForUser1Data_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')); + 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; } } -class _$GPostFragmentForUser1Data extends GPostFragmentForUser1Data { +class _$GPostFragmentForUser2Data extends GPostFragmentForUser2Data { @override final String G__typename; @override final String id; @override - final GPostFragmentForUser1Data_favoritedUsers? favoritedUsers; + final GPostFragmentForUser2Data_favoritedUsers? favoritedUsers; - factory _$GPostFragmentForUser1Data( - [void Function(GPostFragmentForUser1DataBuilder)? updates]) => - (new GPostFragmentForUser1DataBuilder()..update(updates))._build(); + factory _$GPostFragmentForUser2Data( + [void Function(GPostFragmentForUser2DataBuilder)? updates]) => + (new GPostFragmentForUser2DataBuilder()..update(updates))._build(); - _$GPostFragmentForUser1Data._( + _$GPostFragmentForUser2Data._( {required this.G__typename, required this.id, this.favoritedUsers}) : super._() { BuiltValueNullFieldError.checkNotNull( - G__typename, r'GPostFragmentForUser1Data', 'G__typename'); + G__typename, r'GPostFragmentForUser2Data', 'G__typename'); BuiltValueNullFieldError.checkNotNull( - id, r'GPostFragmentForUser1Data', 'id'); + id, r'GPostFragmentForUser2Data', 'id'); } @override - GPostFragmentForUser1Data rebuild( - void Function(GPostFragmentForUser1DataBuilder) updates) => + GPostFragmentForUser2Data rebuild( + void Function(GPostFragmentForUser2DataBuilder) updates) => (toBuilder()..update(updates)).build(); @override - GPostFragmentForUser1DataBuilder toBuilder() => - new GPostFragmentForUser1DataBuilder()..replace(this); + GPostFragmentForUser2DataBuilder toBuilder() => + new GPostFragmentForUser2DataBuilder()..replace(this); @override bool operator ==(Object other) { if (identical(other, this)) return true; - return other is GPostFragmentForUser1Data && + return other is GPostFragmentForUser2Data && G__typename == other.G__typename && id == other.id && favoritedUsers == other.favoritedUsers; @@ -754,7 +733,7 @@ class _$GPostFragmentForUser1Data extends GPostFragmentForUser1Data { @override String toString() { - return (newBuiltValueToStringHelper(r'GPostFragmentForUser1Data') + return (newBuiltValueToStringHelper(r'GPostFragmentForUser2Data') ..add('G__typename', G__typename) ..add('id', id) ..add('favoritedUsers', favoritedUsers)) @@ -762,10 +741,10 @@ class _$GPostFragmentForUser1Data extends GPostFragmentForUser1Data { } } -class GPostFragmentForUser1DataBuilder +class GPostFragmentForUser2DataBuilder implements - Builder { - _$GPostFragmentForUser1Data? _$v; + Builder { + _$GPostFragmentForUser2Data? _$v; String? _G__typename; String? get G__typename => _$this._G__typename; @@ -775,19 +754,19 @@ class GPostFragmentForUser1DataBuilder String? get id => _$this._id; set id(String? id) => _$this._id = id; - GPostFragmentForUser1Data_favoritedUsersBuilder? _favoritedUsers; - GPostFragmentForUser1Data_favoritedUsersBuilder get favoritedUsers => + GPostFragmentForUser2Data_favoritedUsersBuilder? _favoritedUsers; + GPostFragmentForUser2Data_favoritedUsersBuilder get favoritedUsers => _$this._favoritedUsers ??= - new GPostFragmentForUser1Data_favoritedUsersBuilder(); + new GPostFragmentForUser2Data_favoritedUsersBuilder(); set favoritedUsers( - GPostFragmentForUser1Data_favoritedUsersBuilder? favoritedUsers) => + GPostFragmentForUser2Data_favoritedUsersBuilder? favoritedUsers) => _$this._favoritedUsers = favoritedUsers; - GPostFragmentForUser1DataBuilder() { - GPostFragmentForUser1Data._initializeBuilder(this); + GPostFragmentForUser2DataBuilder() { + GPostFragmentForUser2Data._initializeBuilder(this); } - GPostFragmentForUser1DataBuilder get _$this { + GPostFragmentForUser2DataBuilder get _$this { final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; @@ -799,28 +778,28 @@ class GPostFragmentForUser1DataBuilder } @override - void replace(GPostFragmentForUser1Data other) { + void replace(GPostFragmentForUser2Data other) { ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$GPostFragmentForUser1Data; + _$v = other as _$GPostFragmentForUser2Data; } @override - void update(void Function(GPostFragmentForUser1DataBuilder)? updates) { + void update(void Function(GPostFragmentForUser2DataBuilder)? updates) { if (updates != null) updates(this); } @override - GPostFragmentForUser1Data build() => _build(); + GPostFragmentForUser2Data build() => _build(); - _$GPostFragmentForUser1Data _build() { - _$GPostFragmentForUser1Data _$result; + _$GPostFragmentForUser2Data _build() { + _$GPostFragmentForUser2Data _$result; try { _$result = _$v ?? - new _$GPostFragmentForUser1Data._( + new _$GPostFragmentForUser2Data._( G__typename: BuiltValueNullFieldError.checkNotNull( - G__typename, r'GPostFragmentForUser1Data', 'G__typename'), + G__typename, r'GPostFragmentForUser2Data', 'G__typename'), id: BuiltValueNullFieldError.checkNotNull( - id, r'GPostFragmentForUser1Data', 'id'), + id, r'GPostFragmentForUser2Data', 'id'), favoritedUsers: _favoritedUsers?.build()); } catch (_) { late String _$failedField; @@ -829,7 +808,7 @@ class GPostFragmentForUser1DataBuilder _favoritedUsers?.build(); } catch (e) { throw new BuiltValueNestedFieldError( - r'GPostFragmentForUser1Data', _$failedField, e.toString()); + r'GPostFragmentForUser2Data', _$failedField, e.toString()); } rethrow; } @@ -838,42 +817,42 @@ class GPostFragmentForUser1DataBuilder } } -class _$GPostFragmentForUser1Data_favoritedUsers - extends GPostFragmentForUser1Data_favoritedUsers { +class _$GPostFragmentForUser2Data_favoritedUsers + extends GPostFragmentForUser2Data_favoritedUsers { @override final String G__typename; @override final int totalCount; - factory _$GPostFragmentForUser1Data_favoritedUsers( - [void Function(GPostFragmentForUser1Data_favoritedUsersBuilder)? + factory _$GPostFragmentForUser2Data_favoritedUsers( + [void Function(GPostFragmentForUser2Data_favoritedUsersBuilder)? updates]) => - (new GPostFragmentForUser1Data_favoritedUsersBuilder()..update(updates)) + (new GPostFragmentForUser2Data_favoritedUsersBuilder()..update(updates)) ._build(); - _$GPostFragmentForUser1Data_favoritedUsers._( + _$GPostFragmentForUser2Data_favoritedUsers._( {required this.G__typename, required this.totalCount}) : super._() { BuiltValueNullFieldError.checkNotNull(G__typename, - r'GPostFragmentForUser1Data_favoritedUsers', 'G__typename'); + r'GPostFragmentForUser2Data_favoritedUsers', 'G__typename'); BuiltValueNullFieldError.checkNotNull( - totalCount, r'GPostFragmentForUser1Data_favoritedUsers', 'totalCount'); + totalCount, r'GPostFragmentForUser2Data_favoritedUsers', 'totalCount'); } @override - GPostFragmentForUser1Data_favoritedUsers rebuild( - void Function(GPostFragmentForUser1Data_favoritedUsersBuilder) + GPostFragmentForUser2Data_favoritedUsers rebuild( + void Function(GPostFragmentForUser2Data_favoritedUsersBuilder) updates) => (toBuilder()..update(updates)).build(); @override - GPostFragmentForUser1Data_favoritedUsersBuilder toBuilder() => - new GPostFragmentForUser1Data_favoritedUsersBuilder()..replace(this); + GPostFragmentForUser2Data_favoritedUsersBuilder toBuilder() => + new GPostFragmentForUser2Data_favoritedUsersBuilder()..replace(this); @override bool operator ==(Object other) { if (identical(other, this)) return true; - return other is GPostFragmentForUser1Data_favoritedUsers && + return other is GPostFragmentForUser2Data_favoritedUsers && G__typename == other.G__typename && totalCount == other.totalCount; } @@ -890,18 +869,18 @@ class _$GPostFragmentForUser1Data_favoritedUsers @override String toString() { return (newBuiltValueToStringHelper( - r'GPostFragmentForUser1Data_favoritedUsers') + r'GPostFragmentForUser2Data_favoritedUsers') ..add('G__typename', G__typename) ..add('totalCount', totalCount)) .toString(); } } -class GPostFragmentForUser1Data_favoritedUsersBuilder +class GPostFragmentForUser2Data_favoritedUsersBuilder implements - Builder { - _$GPostFragmentForUser1Data_favoritedUsers? _$v; + Builder { + _$GPostFragmentForUser2Data_favoritedUsers? _$v; String? _G__typename; String? get G__typename => _$this._G__typename; @@ -911,11 +890,11 @@ class GPostFragmentForUser1Data_favoritedUsersBuilder int? get totalCount => _$this._totalCount; set totalCount(int? totalCount) => _$this._totalCount = totalCount; - GPostFragmentForUser1Data_favoritedUsersBuilder() { - GPostFragmentForUser1Data_favoritedUsers._initializeBuilder(this); + GPostFragmentForUser2Data_favoritedUsersBuilder() { + GPostFragmentForUser2Data_favoritedUsers._initializeBuilder(this); } - GPostFragmentForUser1Data_favoritedUsersBuilder get _$this { + GPostFragmentForUser2Data_favoritedUsersBuilder get _$this { final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; @@ -926,27 +905,27 @@ class GPostFragmentForUser1Data_favoritedUsersBuilder } @override - void replace(GPostFragmentForUser1Data_favoritedUsers other) { + void replace(GPostFragmentForUser2Data_favoritedUsers other) { ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$GPostFragmentForUser1Data_favoritedUsers; + _$v = other as _$GPostFragmentForUser2Data_favoritedUsers; } @override void update( - void Function(GPostFragmentForUser1Data_favoritedUsersBuilder)? updates) { + void Function(GPostFragmentForUser2Data_favoritedUsersBuilder)? updates) { if (updates != null) updates(this); } @override - GPostFragmentForUser1Data_favoritedUsers build() => _build(); + GPostFragmentForUser2Data_favoritedUsers build() => _build(); - _$GPostFragmentForUser1Data_favoritedUsers _build() { + _$GPostFragmentForUser2Data_favoritedUsers _build() { final _$result = _$v ?? - new _$GPostFragmentForUser1Data_favoritedUsers._( + new _$GPostFragmentForUser2Data_favoritedUsers._( G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, - r'GPostFragmentForUser1Data_favoritedUsers', 'G__typename'), + r'GPostFragmentForUser2Data_favoritedUsers', 'G__typename'), totalCount: BuiltValueNullFieldError.checkNotNull(totalCount, - r'GPostFragmentForUser1Data_favoritedUsers', 'totalCount')); + r'GPostFragmentForUser2Data_favoritedUsers', 'totalCount')); replace(_$result); return _$result; } 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 1c4ede29..7846c1f9 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 @@ -59,3 +59,27 @@ abstract class GPostFragmentForUser1Vars json, ); } + +abstract class GPostFragmentForUser2Vars + implements + Built { + GPostFragmentForUser2Vars._(); + + factory GPostFragmentForUser2Vars( + [void Function(GPostFragmentForUser2VarsBuilder b) updates]) = + _$GPostFragmentForUser2Vars; + + static Serializer get serializer => + _$gPostFragmentForUser2VarsSerializer; + + Map toJson() => (_i2.serializers.serializeWith( + GPostFragmentForUser2Vars.serializer, + this, + ) as Map); + + static GPostFragmentForUser2Vars? fromJson(Map json) => + _i2.serializers.deserializeWith( + GPostFragmentForUser2Vars.serializer, + json, + ); +} 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 f127555f..806abc25 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 @@ -11,6 +11,8 @@ Serializer new _$GPostsWithFixedVariableVarsSerializer(); Serializer _$gPostFragmentForUser1VarsSerializer = new _$GPostFragmentForUser1VarsSerializer(); +Serializer _$gPostFragmentForUser2VarsSerializer = + new _$GPostFragmentForUser2VarsSerializer(); class _$GPostsWithFixedVariableVarsSerializer implements StructuredSerializer { @@ -86,6 +88,31 @@ class _$GPostFragmentForUser1VarsSerializer } } +class _$GPostFragmentForUser2VarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GPostFragmentForUser2Vars, + _$GPostFragmentForUser2Vars + ]; + @override + final String wireName = 'GPostFragmentForUser2Vars'; + + @override + Iterable serialize( + Serializers serializers, GPostFragmentForUser2Vars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GPostFragmentForUser2Vars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GPostFragmentForUser2VarsBuilder().build(); + } +} + class _$GPostsWithFixedVariableVars extends GPostsWithFixedVariableVars { @override final _i1.GJson? filter; @@ -244,4 +271,65 @@ class GPostFragmentForUser1VarsBuilder } } +class _$GPostFragmentForUser2Vars extends GPostFragmentForUser2Vars { + factory _$GPostFragmentForUser2Vars( + [void Function(GPostFragmentForUser2VarsBuilder)? updates]) => + (new GPostFragmentForUser2VarsBuilder()..update(updates))._build(); + + _$GPostFragmentForUser2Vars._() : super._(); + + @override + GPostFragmentForUser2Vars rebuild( + void Function(GPostFragmentForUser2VarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GPostFragmentForUser2VarsBuilder toBuilder() => + new GPostFragmentForUser2VarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GPostFragmentForUser2Vars; + } + + @override + int get hashCode { + return 560444928; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GPostFragmentForUser2Vars').toString(); + } +} + +class GPostFragmentForUser2VarsBuilder + implements + Builder { + _$GPostFragmentForUser2Vars? _$v; + + GPostFragmentForUser2VarsBuilder(); + + @override + void replace(GPostFragmentForUser2Vars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GPostFragmentForUser2Vars; + } + + @override + void update(void Function(GPostFragmentForUser2VarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GPostFragmentForUser2Vars build() => _build(); + + _$GPostFragmentForUser2Vars _build() { + final _$result = _$v ?? new _$GPostFragmentForUser2Vars._(); + replace(_$result); + return _$result; + } +} + // 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.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.data.gql.dart index a447049b..b041b509 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.data.gql.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.data.gql.dart @@ -23,7 +23,7 @@ abstract class GHeroWithFragmentsData @BuiltValueField(wireName: '__typename') String get G__typename; - GHeroWithFragmentsData_hero? get hero; + GcomparisonFieldsData get hero; static Serializer get serializer => _$gHeroWithFragmentsDataSerializer; @@ -39,162 +39,6 @@ abstract class GHeroWithFragmentsData ); } -abstract class GHeroWithFragmentsData_hero - implements - Built, - GcomparisonFields { - GHeroWithFragmentsData_hero._(); - - factory GHeroWithFragmentsData_hero( - [void 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( - [void 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( - [void 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( - [void 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; @@ -251,17 +95,7 @@ abstract class GcomparisonFields_friendsConnection { 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 + GheroDataData get node; Map toJson(); } @@ -362,7 +196,7 @@ abstract class GcomparisonFieldsData_friendsConnection_edges @BuiltValueField(wireName: '__typename') String get G__typename; @override - GcomparisonFieldsData_friendsConnection_edges_node? get node; + GheroDataData get node; static Serializer get serializer => _$gcomparisonFieldsDataFriendsConnectionEdgesSerializer; @@ -379,43 +213,3 @@ abstract class GcomparisonFieldsData_friendsConnection_edges json, ); } - -abstract class GcomparisonFieldsData_friendsConnection_edges_node - implements - Built, - GcomparisonFields_friendsConnection_edges_node, - GheroData { - GcomparisonFieldsData_friendsConnection_edges_node._(); - - factory GcomparisonFieldsData_friendsConnection_edges_node( - [void 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/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 b5005f79..d98b612d 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 @@ -8,17 +8,6 @@ part of 'hero_with_fragments.data.gql.dart'; 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 = @@ -29,9 +18,6 @@ Serializer Serializer _$gcomparisonFieldsDataFriendsConnectionEdgesSerializer = new _$GcomparisonFieldsData_friendsConnection_edgesSerializer(); -Serializer - _$gcomparisonFieldsDataFriendsConnectionEdgesNodeSerializer = - new _$GcomparisonFieldsData_friendsConnection_edges_nodeSerializer(); class _$GHeroWithFragmentsDataSerializer implements StructuredSerializer { @@ -51,15 +37,11 @@ class _$GHeroWithFragmentsDataSerializer '__typename', serializers.serialize(object.G__typename, specifiedType: const FullType(String)), + 'hero', + serializers.serialize(object.hero, + specifiedType: const FullType(GcomparisonFieldsData)), ]; - Object? value; - value = object.hero; - if (value != null) { - result - ..add('hero') - ..add(serializers.serialize(value, - specifiedType: const FullType(GHeroWithFragmentsData_hero))); - } + return result; } @@ -81,269 +63,8 @@ class _$GHeroWithFragmentsDataSerializer 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; + specifiedType: const FullType(GcomparisonFieldsData))! + as GcomparisonFieldsData); break; } } @@ -503,839 +224,210 @@ class _$GcomparisonFieldsData_friendsConnectionSerializer 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; + return result; } @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); - } + GcomparisonFieldsData_friendsConnection deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GcomparisonFieldsData_friendsConnectionBuilder(); - GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder get _$this { - final $v = _$v; - if ($v != null) { - _G__typename = $v.G__typename; - _node = $v.node?.toBuilder(); - _$v = null; + 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 this; + + return result.build(); } +} +class _$GcomparisonFieldsData_friendsConnection_edgesSerializer + implements + StructuredSerializer { @override - void replace(GHeroWithFragmentsData_hero_friendsConnection_edges other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$GHeroWithFragmentsData_hero_friendsConnection_edges; - } + final Iterable types = const [ + GcomparisonFieldsData_friendsConnection_edges, + _$GcomparisonFieldsData_friendsConnection_edges + ]; + @override + final String wireName = 'GcomparisonFieldsData_friendsConnection_edges'; @override - void update( - void Function(GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder)? - updates) { - if (updates != null) updates(this); + Iterable serialize(Serializers serializers, + GcomparisonFieldsData_friendsConnection_edges object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'node', + serializers.serialize(object.node, + specifiedType: const FullType(GheroDataData)), + ]; + + return result; } @override - GHeroWithFragmentsData_hero_friendsConnection_edges build() => _build(); + GcomparisonFieldsData_friendsConnection_edges deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GcomparisonFieldsData_friendsConnection_edgesBuilder(); - _$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()); + 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(GheroDataData))! as GheroDataData); + break; } - rethrow; } - replace(_$result); - return _$result; + + return result.build(); } } -class _$GHeroWithFragmentsData_hero_friendsConnection_edges_node - extends GHeroWithFragmentsData_hero_friendsConnection_edges_node { +class _$GHeroWithFragmentsData extends GHeroWithFragmentsData { @override final String G__typename; @override - final String name; + final GcomparisonFieldsData hero; - factory _$GHeroWithFragmentsData_hero_friendsConnection_edges_node( - [void Function( - GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder)? - updates]) => - (new GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder() - ..update(updates)) - ._build(); + factory _$GHeroWithFragmentsData( + [void Function(GHeroWithFragmentsDataBuilder)? updates]) => + (new GHeroWithFragmentsDataBuilder()..update(updates))._build(); - _$GHeroWithFragmentsData_hero_friendsConnection_edges_node._( - {required this.G__typename, required this.name}) + _$GHeroWithFragmentsData._({required this.G__typename, required this.hero}) : super._() { BuiltValueNullFieldError.checkNotNull( - G__typename, - r'GHeroWithFragmentsData_hero_friendsConnection_edges_node', - 'G__typename'); - BuiltValueNullFieldError.checkNotNull(name, - r'GHeroWithFragmentsData_hero_friendsConnection_edges_node', 'name'); + G__typename, r'GHeroWithFragmentsData', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + hero, r'GHeroWithFragmentsData', 'hero'); } @override - GHeroWithFragmentsData_hero_friendsConnection_edges_node rebuild( - void Function( - GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder) - updates) => + GHeroWithFragmentsData rebuild( + void Function(GHeroWithFragmentsDataBuilder) updates) => (toBuilder()..update(updates)).build(); @override - GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder toBuilder() => - new GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder() - ..replace(this); + GHeroWithFragmentsDataBuilder toBuilder() => + new GHeroWithFragmentsDataBuilder()..replace(this); @override bool operator ==(Object other) { if (identical(other, this)) return true; - return other is GHeroWithFragmentsData_hero_friendsConnection_edges_node && + return other is GHeroWithFragmentsData && G__typename == other.G__typename && - name == other.name; + hero == other.hero; } @override int get hashCode { var _$hash = 0; _$hash = $jc(_$hash, G__typename.hashCode); - _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, hero.hashCode); _$hash = $jf(_$hash); return _$hash; } @override String toString() { - return (newBuiltValueToStringHelper( - r'GHeroWithFragmentsData_hero_friendsConnection_edges_node') + return (newBuiltValueToStringHelper(r'GHeroWithFragmentsData') ..add('G__typename', G__typename) - ..add('name', name)) + ..add('hero', hero)) .toString(); } } -class GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder - implements - Builder { - _$GHeroWithFragmentsData_hero_friendsConnection_edges_node? _$v; +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; - String? _name; - String? get name => _$this._name; - set name(String? name) => _$this._name = name; + GcomparisonFieldsDataBuilder? _hero; + GcomparisonFieldsDataBuilder get hero => + _$this._hero ??= new GcomparisonFieldsDataBuilder(); + set hero(GcomparisonFieldsDataBuilder? hero) => _$this._hero = hero; - GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder() { - GHeroWithFragmentsData_hero_friendsConnection_edges_node._initializeBuilder( - this); + GHeroWithFragmentsDataBuilder() { + GHeroWithFragmentsData._initializeBuilder(this); } - GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder get _$this { + GHeroWithFragmentsDataBuilder get _$this { final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; - _name = $v.name; + _hero = $v.hero.toBuilder(); _$v = null; } return this; } @override - void replace(GHeroWithFragmentsData_hero_friendsConnection_edges_node other) { + void replace(GHeroWithFragmentsData other) { ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$GHeroWithFragmentsData_hero_friendsConnection_edges_node; + _$v = other as _$GHeroWithFragmentsData; } @override - void update( - void Function( - GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder)? - updates) { + void update(void Function(GHeroWithFragmentsDataBuilder)? updates) { if (updates != null) updates(this); } @override - GHeroWithFragmentsData_hero_friendsConnection_edges_node build() => _build(); + GHeroWithFragmentsData 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')); + _$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; } @@ -1740,7 +832,7 @@ class _$GcomparisonFieldsData_friendsConnection_edges @override final String G__typename; @override - final GcomparisonFieldsData_friendsConnection_edges_node? node; + final GheroDataData node; factory _$GcomparisonFieldsData_friendsConnection_edges( [void Function(GcomparisonFieldsData_friendsConnection_edgesBuilder)? @@ -1750,10 +842,12 @@ class _$GcomparisonFieldsData_friendsConnection_edges ._build(); _$GcomparisonFieldsData_friendsConnection_edges._( - {required this.G__typename, this.node}) + {required this.G__typename, required this.node}) : super._() { BuiltValueNullFieldError.checkNotNull(G__typename, r'GcomparisonFieldsData_friendsConnection_edges', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + node, r'GcomparisonFieldsData_friendsConnection_edges', 'node'); } @override @@ -1803,12 +897,9 @@ class GcomparisonFieldsData_friendsConnection_edgesBuilder 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; + GheroDataDataBuilder? _node; + GheroDataDataBuilder get node => _$this._node ??= new GheroDataDataBuilder(); + set node(GheroDataDataBuilder? node) => _$this._node = node; GcomparisonFieldsData_friendsConnection_edgesBuilder() { GcomparisonFieldsData_friendsConnection_edges._initializeBuilder(this); @@ -1818,7 +909,7 @@ class GcomparisonFieldsData_friendsConnection_edgesBuilder final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; - _node = $v.node?.toBuilder(); + _node = $v.node.toBuilder(); _$v = null; } return this; @@ -1849,12 +940,12 @@ class GcomparisonFieldsData_friendsConnection_edgesBuilder G__typename, r'GcomparisonFieldsData_friendsConnection_edges', 'G__typename'), - node: _node?.build()); + node: node.build()); } catch (_) { late String _$failedField; try { _$failedField = 'node'; - _node?.build(); + node.build(); } catch (e) { throw new BuiltValueNestedFieldError( r'GcomparisonFieldsData_friendsConnection_edges', @@ -1868,125 +959,4 @@ class GcomparisonFieldsData_friendsConnection_edgesBuilder } } -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/lib/fragments/fragment_with_scalar_var.graphql b/codegen/end_to_end_test/lib/fragments/fragment_with_scalar_var.graphql index 1de12ca1..64695fea 100644 --- a/codegen/end_to_end_test/lib/fragments/fragment_with_scalar_var.graphql +++ b/codegen/end_to_end_test/lib/fragments/fragment_with_scalar_var.graphql @@ -5,6 +5,13 @@ fragment PostFragmentForUser1 on Post { } } +fragment PostFragmentForUser2 on Post { + id + favoritedUsers(filter: {premium: true}) { + totalCount + } +} + query PostsWithFixedVariable($filter: Json) { posts(filter: $filter) { ...PostFragmentForUser1 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 49b68ce0..8b1a78bc 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 @@ -6,10 +6,7 @@ import 'package:end_to_end_test/aliases/__generated__/alias_var_fragment.data.gq GPostFragmentData, GPostFragmentData_isFavorited, GPostFragmentData_isLiked, - GPostsData, - GPostsData_posts, - GPostsData_posts_isFavorited, - GPostsData_posts_isLiked; + GPostsData; import 'package:end_to_end_test/aliases/__generated__/alias_var_fragment.req.gql.dart' show GPosts; import 'package:end_to_end_test/aliases/__generated__/alias_var_fragment.var.gql.dart' @@ -31,24 +28,22 @@ import 'package:end_to_end_test/fragments/__generated__/fragment_with_scalar_var show GPostFragmentForUser1Data, GPostFragmentForUser1Data_favoritedUsers, - GPostsWithFixedVariableData, - GPostsWithFixedVariableData_posts, - GPostsWithFixedVariableData_posts_favoritedUsers; + GPostFragmentForUser2Data, + GPostFragmentForUser2Data_favoritedUsers, + GPostsWithFixedVariableData; import 'package:end_to_end_test/fragments/__generated__/fragment_with_scalar_var.req.gql.dart' show GPostsWithFixedVariable; import 'package:end_to_end_test/fragments/__generated__/fragment_with_scalar_var.var.gql.dart' - show GPostFragmentForUser1Vars, GPostsWithFixedVariableVars; + show + GPostFragmentForUser1Vars, + GPostFragmentForUser2Vars, + GPostsWithFixedVariableVars; import 'package:end_to_end_test/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/fragments/__generated__/hero_with_fragments.req.gql.dart' show GHeroWithFragments; @@ -193,10 +188,6 @@ final SerializersBuilder _serializersBuilder = _$serializers.toBuilder() GHeroWith2FragmentsVars, GHeroWithFragments, GHeroWithFragmentsData, - GHeroWithFragmentsData_hero, - GHeroWithFragmentsData_hero_friendsConnection, - GHeroWithFragmentsData_hero_friendsConnection_edges, - GHeroWithFragmentsData_hero_friendsConnection_edges_node, GHeroWithFragmentsVars, GHeroWithInterfaceSubTypedFragments, GHeroWithInterfaceSubTypedFragmentsData, @@ -216,18 +207,16 @@ final SerializersBuilder _serializersBuilder = _$serializers.toBuilder() GPostFragmentForUser1Data, GPostFragmentForUser1Data_favoritedUsers, GPostFragmentForUser1Vars, + GPostFragmentForUser2Data, + GPostFragmentForUser2Data_favoritedUsers, + GPostFragmentForUser2Vars, GPostFragmentVars, GPostLikesInput, GPosts, GPostsData, - GPostsData_posts, - GPostsData_posts_isFavorited, - GPostsData_posts_isLiked, GPostsVars, GPostsWithFixedVariable, GPostsWithFixedVariableData, - GPostsWithFixedVariableData_posts, - GPostsWithFixedVariableData_posts_favoritedUsers, GPostsWithFixedVariableVars, GReviewInput, GReviewWithDate, @@ -237,7 +226,6 @@ final SerializersBuilder _serializersBuilder = _$serializers.toBuilder() GcomparisonFieldsData, GcomparisonFieldsData_friendsConnection, GcomparisonFieldsData_friendsConnection_edges, - GcomparisonFieldsData_friendsConnection_edges_node, GcomparisonFieldsVars, GdroidFieldsFragmentData, GdroidFieldsFragmentVars, 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 6e8208e2..a6594e80 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 @@ -41,10 +41,6 @@ Serializers _$serializers = (new Serializers().toBuilder() ..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) @@ -64,18 +60,16 @@ Serializers _$serializers = (new Serializers().toBuilder() ..add(GPostFragmentForUser1Data.serializer) ..add(GPostFragmentForUser1Data_favoritedUsers.serializer) ..add(GPostFragmentForUser1Vars.serializer) + ..add(GPostFragmentForUser2Data.serializer) + ..add(GPostFragmentForUser2Data_favoritedUsers.serializer) + ..add(GPostFragmentForUser2Vars.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) @@ -85,7 +79,6 @@ Serializers _$serializers = (new Serializers().toBuilder() ..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) @@ -132,22 +125,6 @@ Serializers _$serializers = (new Serializers().toBuilder() 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( diff --git a/codegen/end_to_end_test/pubspec.yaml b/codegen/end_to_end_test/pubspec.yaml index a44d3a61..886e4976 100644 --- a/codegen/end_to_end_test/pubspec.yaml +++ b/codegen/end_to_end_test/pubspec.yaml @@ -15,3 +15,42 @@ 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_tristate_value: + path: ../gql_tristate_value + 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 + end_to_end_test_tristate: + path: ../end_to_end_test_tristate From 22b04ae2bb1958c20bc48668af4f2c8f2d6fcf37 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 7 Jan 2024 05:27:28 +0000 Subject: [PATCH 03/12] simpler version of reuse fragments with less scope --- .../nested_fragments.ast.gql.dart | 134 +++ .../nested_fragments.data.gql.dart | 171 ++++ .../nested_fragments.data.gql.g.dart | 778 ++++++++++++++++++ .../nested_fragments.req.gql.dart | 43 + .../nested_fragments.req.gql.g.dart | 171 ++++ .../nested_fragments.var.gql.dart | 55 ++ .../nested_fragments.var.gql.g.dart | 173 ++++ .../lib/fragments/nested_fragments.graphql | 28 + .../graphql/__generated__/schema.ast.gql.dart | 106 +++ .../__generated__/schema.schema.gql.dart | 18 + .../__generated__/schema.schema.gql.g.dart | 47 ++ .../__generated__/serializers.gql.dart | 19 + .../__generated__/serializers.gql.g.dart | 8 + .../lib/graphql/schema.graphql | 23 + 14 files changed, 1774 insertions(+) create mode 100644 codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.ast.gql.dart create mode 100644 codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.dart create mode 100644 codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.g.dart create mode 100644 codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.req.gql.dart create mode 100644 codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.req.gql.g.dart create mode 100644 codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.var.gql.dart create mode 100644 codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.var.gql.g.dart create mode 100644 codegen/end_to_end_test/lib/fragments/nested_fragments.graphql diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.ast.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.ast.gql.dart new file mode 100644 index 00000000..387cd69a --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.ast.gql.dart @@ -0,0 +1,134 @@ +// 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 TestQuery = _i1.OperationDefinitionNode( + type: _i1.OperationType.query, + name: _i1.NameNode(value: 'TestQuery'), + variableDefinitions: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'currentUser'), + alias: null, + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'UserFragment'), + directives: [], + ) + ]), + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'currentUser'), + alias: _i1.NameNode(value: 'currentUser2'), + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'UserFragment'), + directives: [], + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'location'), + alias: null, + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'lat'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'lng'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'moderation'), + alias: null, + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'moderationStatus'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), + ), + ]), + ), + ]), +); +const UserFragment = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'UserFragment'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'User'), + 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: 'location'), + alias: null, + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'lat'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'lng'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + ]), + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'moderation'), + alias: null, + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: 'moderationStatus'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), + ), + ]), +); +const document = _i1.DocumentNode(definitions: [ + TestQuery, + UserFragment, +]); diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.dart new file mode 100644 index 00000000..327f40f9 --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.dart @@ -0,0 +1,171 @@ +// 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 _i2; +import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'nested_fragments.data.gql.g.dart'; + +abstract class GTestQueryData + implements Built { + GTestQueryData._(); + + factory GTestQueryData([void Function(GTestQueryDataBuilder b) updates]) = + _$GTestQueryData; + + static void _initializeBuilder(GTestQueryDataBuilder b) => + b..G__typename = 'Query'; + + @BuiltValueField(wireName: '__typename') + String get G__typename; + GUserFragmentData get currentUser; + GUserFragmentData get currentUser2; + static Serializer get serializer => + _$gTestQueryDataSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GTestQueryData.serializer, + this, + ) as Map); + + static GTestQueryData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GTestQueryData.serializer, + json, + ); +} + +abstract class GUserFragment { + String get G__typename; + String get id; + GUserFragment_location? get location; + GUserFragment_moderation? get moderation; + Map toJson(); +} + +abstract class GUserFragment_location { + String get G__typename; + double get lat; + double get lng; + Map toJson(); +} + +abstract class GUserFragment_moderation { + String get G__typename; + _i2.GModerationStatus get moderationStatus; + Map toJson(); +} + +abstract class GUserFragmentData + implements + Built, + GUserFragment { + GUserFragmentData._(); + + factory GUserFragmentData( + [void Function(GUserFragmentDataBuilder b) updates]) = + _$GUserFragmentData; + + static void _initializeBuilder(GUserFragmentDataBuilder b) => + b..G__typename = 'User'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + String get id; + @override + GUserFragmentData_location? get location; + @override + GUserFragmentData_moderation? get moderation; + static Serializer get serializer => + _$gUserFragmentDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GUserFragmentData.serializer, + this, + ) as Map); + + static GUserFragmentData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GUserFragmentData.serializer, + json, + ); +} + +abstract class GUserFragmentData_location + implements + Built, + GUserFragment_location { + GUserFragmentData_location._(); + + factory GUserFragmentData_location( + [void Function(GUserFragmentData_locationBuilder b) updates]) = + _$GUserFragmentData_location; + + static void _initializeBuilder(GUserFragmentData_locationBuilder b) => + b..G__typename = 'Location'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + double get lat; + @override + double get lng; + static Serializer get serializer => + _$gUserFragmentDataLocationSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GUserFragmentData_location.serializer, + this, + ) as Map); + + static GUserFragmentData_location? fromJson(Map json) => + _i1.serializers.deserializeWith( + GUserFragmentData_location.serializer, + json, + ); +} + +abstract class GUserFragmentData_moderation + implements + Built, + GUserFragment_moderation { + GUserFragmentData_moderation._(); + + factory GUserFragmentData_moderation( + [void Function(GUserFragmentData_moderationBuilder b) updates]) = + _$GUserFragmentData_moderation; + + static void _initializeBuilder(GUserFragmentData_moderationBuilder b) => + b..G__typename = 'Moderation'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + _i2.GModerationStatus get moderationStatus; + static Serializer get serializer => + _$gUserFragmentDataModerationSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GUserFragmentData_moderation.serializer, + this, + ) as Map); + + static GUserFragmentData_moderation? fromJson(Map json) => + _i1.serializers.deserializeWith( + GUserFragmentData_moderation.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.g.dart new file mode 100644 index 00000000..e8a20354 --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.g.dart @@ -0,0 +1,778 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'nested_fragments.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gTestQueryDataSerializer = + new _$GTestQueryDataSerializer(); +Serializer _$gUserFragmentDataSerializer = + new _$GUserFragmentDataSerializer(); +Serializer _$gUserFragmentDataLocationSerializer = + new _$GUserFragmentData_locationSerializer(); +Serializer + _$gUserFragmentDataModerationSerializer = + new _$GUserFragmentData_moderationSerializer(); + +class _$GTestQueryDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GTestQueryData, _$GTestQueryData]; + @override + final String wireName = 'GTestQueryData'; + + @override + Iterable serialize(Serializers serializers, GTestQueryData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'currentUser', + serializers.serialize(object.currentUser, + specifiedType: const FullType(GUserFragmentData)), + 'currentUser2', + serializers.serialize(object.currentUser2, + specifiedType: const FullType(GUserFragmentData)), + ]; + + return result; + } + + @override + GTestQueryData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GTestQueryDataBuilder(); + + 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 'currentUser': + result.currentUser.replace(serializers.deserialize(value, + specifiedType: const FullType(GUserFragmentData))! + as GUserFragmentData); + break; + case 'currentUser2': + result.currentUser2.replace(serializers.deserialize(value, + specifiedType: const FullType(GUserFragmentData))! + as GUserFragmentData); + break; + } + } + + return result.build(); + } +} + +class _$GUserFragmentDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GUserFragmentData, _$GUserFragmentData]; + @override + final String wireName = 'GUserFragmentData'; + + @override + Iterable serialize(Serializers serializers, GUserFragmentData 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.location; + if (value != null) { + result + ..add('location') + ..add(serializers.serialize(value, + specifiedType: const FullType(GUserFragmentData_location))); + } + value = object.moderation; + if (value != null) { + result + ..add('moderation') + ..add(serializers.serialize(value, + specifiedType: const FullType(GUserFragmentData_moderation))); + } + return result; + } + + @override + GUserFragmentData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GUserFragmentDataBuilder(); + + 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 'location': + result.location.replace(serializers.deserialize(value, + specifiedType: const FullType(GUserFragmentData_location))! + as GUserFragmentData_location); + break; + case 'moderation': + result.moderation.replace(serializers.deserialize(value, + specifiedType: const FullType(GUserFragmentData_moderation))! + as GUserFragmentData_moderation); + break; + } + } + + return result.build(); + } +} + +class _$GUserFragmentData_locationSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GUserFragmentData_location, + _$GUserFragmentData_location + ]; + @override + final String wireName = 'GUserFragmentData_location'; + + @override + Iterable serialize( + Serializers serializers, GUserFragmentData_location object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'lat', + serializers.serialize(object.lat, specifiedType: const FullType(double)), + 'lng', + serializers.serialize(object.lng, specifiedType: const FullType(double)), + ]; + + return result; + } + + @override + GUserFragmentData_location deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GUserFragmentData_locationBuilder(); + + 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 'lat': + result.lat = serializers.deserialize(value, + specifiedType: const FullType(double))! as double; + break; + case 'lng': + result.lng = serializers.deserialize(value, + specifiedType: const FullType(double))! as double; + break; + } + } + + return result.build(); + } +} + +class _$GUserFragmentData_moderationSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GUserFragmentData_moderation, + _$GUserFragmentData_moderation + ]; + @override + final String wireName = 'GUserFragmentData_moderation'; + + @override + Iterable serialize( + Serializers serializers, GUserFragmentData_moderation object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'moderationStatus', + serializers.serialize(object.moderationStatus, + specifiedType: const FullType(_i2.GModerationStatus)), + ]; + + return result; + } + + @override + GUserFragmentData_moderation deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GUserFragmentData_moderationBuilder(); + + 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 'moderationStatus': + result.moderationStatus = serializers.deserialize(value, + specifiedType: const FullType(_i2.GModerationStatus))! + as _i2.GModerationStatus; + break; + } + } + + return result.build(); + } +} + +class _$GTestQueryData extends GTestQueryData { + @override + final String G__typename; + @override + final GUserFragmentData currentUser; + @override + final GUserFragmentData currentUser2; + + factory _$GTestQueryData([void Function(GTestQueryDataBuilder)? updates]) => + (new GTestQueryDataBuilder()..update(updates))._build(); + + _$GTestQueryData._( + {required this.G__typename, + required this.currentUser, + required this.currentUser2}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GTestQueryData', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + currentUser, r'GTestQueryData', 'currentUser'); + BuiltValueNullFieldError.checkNotNull( + currentUser2, r'GTestQueryData', 'currentUser2'); + } + + @override + GTestQueryData rebuild(void Function(GTestQueryDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GTestQueryDataBuilder toBuilder() => + new GTestQueryDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GTestQueryData && + G__typename == other.G__typename && + currentUser == other.currentUser && + currentUser2 == other.currentUser2; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, currentUser.hashCode); + _$hash = $jc(_$hash, currentUser2.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GTestQueryData') + ..add('G__typename', G__typename) + ..add('currentUser', currentUser) + ..add('currentUser2', currentUser2)) + .toString(); + } +} + +class GTestQueryDataBuilder + implements Builder { + _$GTestQueryData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GUserFragmentDataBuilder? _currentUser; + GUserFragmentDataBuilder get currentUser => + _$this._currentUser ??= new GUserFragmentDataBuilder(); + set currentUser(GUserFragmentDataBuilder? currentUser) => + _$this._currentUser = currentUser; + + GUserFragmentDataBuilder? _currentUser2; + GUserFragmentDataBuilder get currentUser2 => + _$this._currentUser2 ??= new GUserFragmentDataBuilder(); + set currentUser2(GUserFragmentDataBuilder? currentUser2) => + _$this._currentUser2 = currentUser2; + + GTestQueryDataBuilder() { + GTestQueryData._initializeBuilder(this); + } + + GTestQueryDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _currentUser = $v.currentUser.toBuilder(); + _currentUser2 = $v.currentUser2.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GTestQueryData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GTestQueryData; + } + + @override + void update(void Function(GTestQueryDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GTestQueryData build() => _build(); + + _$GTestQueryData _build() { + _$GTestQueryData _$result; + try { + _$result = _$v ?? + new _$GTestQueryData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GTestQueryData', 'G__typename'), + currentUser: currentUser.build(), + currentUser2: currentUser2.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'currentUser'; + currentUser.build(); + _$failedField = 'currentUser2'; + currentUser2.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GTestQueryData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GUserFragmentData extends GUserFragmentData { + @override + final String G__typename; + @override + final String id; + @override + final GUserFragmentData_location? location; + @override + final GUserFragmentData_moderation? moderation; + + factory _$GUserFragmentData( + [void Function(GUserFragmentDataBuilder)? updates]) => + (new GUserFragmentDataBuilder()..update(updates))._build(); + + _$GUserFragmentData._( + {required this.G__typename, + required this.id, + this.location, + this.moderation}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GUserFragmentData', 'G__typename'); + BuiltValueNullFieldError.checkNotNull(id, r'GUserFragmentData', 'id'); + } + + @override + GUserFragmentData rebuild(void Function(GUserFragmentDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GUserFragmentDataBuilder toBuilder() => + new GUserFragmentDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GUserFragmentData && + G__typename == other.G__typename && + id == other.id && + location == other.location && + moderation == other.moderation; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, id.hashCode); + _$hash = $jc(_$hash, location.hashCode); + _$hash = $jc(_$hash, moderation.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GUserFragmentData') + ..add('G__typename', G__typename) + ..add('id', id) + ..add('location', location) + ..add('moderation', moderation)) + .toString(); + } +} + +class GUserFragmentDataBuilder + implements Builder { + _$GUserFragmentData? _$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; + + GUserFragmentData_locationBuilder? _location; + GUserFragmentData_locationBuilder get location => + _$this._location ??= new GUserFragmentData_locationBuilder(); + set location(GUserFragmentData_locationBuilder? location) => + _$this._location = location; + + GUserFragmentData_moderationBuilder? _moderation; + GUserFragmentData_moderationBuilder get moderation => + _$this._moderation ??= new GUserFragmentData_moderationBuilder(); + set moderation(GUserFragmentData_moderationBuilder? moderation) => + _$this._moderation = moderation; + + GUserFragmentDataBuilder() { + GUserFragmentData._initializeBuilder(this); + } + + GUserFragmentDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _id = $v.id; + _location = $v.location?.toBuilder(); + _moderation = $v.moderation?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GUserFragmentData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GUserFragmentData; + } + + @override + void update(void Function(GUserFragmentDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GUserFragmentData build() => _build(); + + _$GUserFragmentData _build() { + _$GUserFragmentData _$result; + try { + _$result = _$v ?? + new _$GUserFragmentData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GUserFragmentData', 'G__typename'), + id: BuiltValueNullFieldError.checkNotNull( + id, r'GUserFragmentData', 'id'), + location: _location?.build(), + moderation: _moderation?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'location'; + _location?.build(); + _$failedField = 'moderation'; + _moderation?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GUserFragmentData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GUserFragmentData_location extends GUserFragmentData_location { + @override + final String G__typename; + @override + final double lat; + @override + final double lng; + + factory _$GUserFragmentData_location( + [void Function(GUserFragmentData_locationBuilder)? updates]) => + (new GUserFragmentData_locationBuilder()..update(updates))._build(); + + _$GUserFragmentData_location._( + {required this.G__typename, required this.lat, required this.lng}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GUserFragmentData_location', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + lat, r'GUserFragmentData_location', 'lat'); + BuiltValueNullFieldError.checkNotNull( + lng, r'GUserFragmentData_location', 'lng'); + } + + @override + GUserFragmentData_location rebuild( + void Function(GUserFragmentData_locationBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GUserFragmentData_locationBuilder toBuilder() => + new GUserFragmentData_locationBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GUserFragmentData_location && + G__typename == other.G__typename && + lat == other.lat && + lng == other.lng; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, lat.hashCode); + _$hash = $jc(_$hash, lng.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GUserFragmentData_location') + ..add('G__typename', G__typename) + ..add('lat', lat) + ..add('lng', lng)) + .toString(); + } +} + +class GUserFragmentData_locationBuilder + implements + Builder { + _$GUserFragmentData_location? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + double? _lat; + double? get lat => _$this._lat; + set lat(double? lat) => _$this._lat = lat; + + double? _lng; + double? get lng => _$this._lng; + set lng(double? lng) => _$this._lng = lng; + + GUserFragmentData_locationBuilder() { + GUserFragmentData_location._initializeBuilder(this); + } + + GUserFragmentData_locationBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _lat = $v.lat; + _lng = $v.lng; + _$v = null; + } + return this; + } + + @override + void replace(GUserFragmentData_location other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GUserFragmentData_location; + } + + @override + void update(void Function(GUserFragmentData_locationBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GUserFragmentData_location build() => _build(); + + _$GUserFragmentData_location _build() { + final _$result = _$v ?? + new _$GUserFragmentData_location._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GUserFragmentData_location', 'G__typename'), + lat: BuiltValueNullFieldError.checkNotNull( + lat, r'GUserFragmentData_location', 'lat'), + lng: BuiltValueNullFieldError.checkNotNull( + lng, r'GUserFragmentData_location', 'lng')); + replace(_$result); + return _$result; + } +} + +class _$GUserFragmentData_moderation extends GUserFragmentData_moderation { + @override + final String G__typename; + @override + final _i2.GModerationStatus moderationStatus; + + factory _$GUserFragmentData_moderation( + [void Function(GUserFragmentData_moderationBuilder)? updates]) => + (new GUserFragmentData_moderationBuilder()..update(updates))._build(); + + _$GUserFragmentData_moderation._( + {required this.G__typename, required this.moderationStatus}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GUserFragmentData_moderation', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + moderationStatus, r'GUserFragmentData_moderation', 'moderationStatus'); + } + + @override + GUserFragmentData_moderation rebuild( + void Function(GUserFragmentData_moderationBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GUserFragmentData_moderationBuilder toBuilder() => + new GUserFragmentData_moderationBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GUserFragmentData_moderation && + G__typename == other.G__typename && + moderationStatus == other.moderationStatus; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, moderationStatus.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GUserFragmentData_moderation') + ..add('G__typename', G__typename) + ..add('moderationStatus', moderationStatus)) + .toString(); + } +} + +class GUserFragmentData_moderationBuilder + implements + Builder { + _$GUserFragmentData_moderation? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + _i2.GModerationStatus? _moderationStatus; + _i2.GModerationStatus? get moderationStatus => _$this._moderationStatus; + set moderationStatus(_i2.GModerationStatus? moderationStatus) => + _$this._moderationStatus = moderationStatus; + + GUserFragmentData_moderationBuilder() { + GUserFragmentData_moderation._initializeBuilder(this); + } + + GUserFragmentData_moderationBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _moderationStatus = $v.moderationStatus; + _$v = null; + } + return this; + } + + @override + void replace(GUserFragmentData_moderation other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GUserFragmentData_moderation; + } + + @override + void update(void Function(GUserFragmentData_moderationBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GUserFragmentData_moderation build() => _build(); + + _$GUserFragmentData_moderation _build() { + final _$result = _$v ?? + new _$GUserFragmentData_moderation._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GUserFragmentData_moderation', 'G__typename'), + moderationStatus: BuiltValueNullFieldError.checkNotNull( + moderationStatus, + r'GUserFragmentData_moderation', + 'moderationStatus')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.req.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.req.gql.dart new file mode 100644 index 00000000..632fe229 --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.req.gql.dart @@ -0,0 +1,43 @@ +// 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/fragments/__generated__/nested_fragments.ast.gql.dart' + as _i2; +import 'package:end_to_end_test/fragments/__generated__/nested_fragments.var.gql.dart' + as _i3; +import 'package:end_to_end_test/graphql/__generated__/serializers.gql.dart' + as _i4; +import 'package:gql_exec/gql_exec.dart' as _i1; + +part 'nested_fragments.req.gql.g.dart'; + +abstract class GTestQuery implements Built { + GTestQuery._(); + + factory GTestQuery([void Function(GTestQueryBuilder b) updates]) = + _$GTestQuery; + + static void _initializeBuilder(GTestQueryBuilder b) => b + ..operation = _i1.Operation( + document: _i2.document, + operationName: 'TestQuery', + ); + + _i3.GTestQueryVars get vars; + _i1.Operation get operation; + static Serializer get serializer => _$gTestQuerySerializer; + + Map toJson() => (_i4.serializers.serializeWith( + GTestQuery.serializer, + this, + ) as Map); + + static GTestQuery? fromJson(Map json) => + _i4.serializers.deserializeWith( + GTestQuery.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.req.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.req.gql.g.dart new file mode 100644 index 00000000..4c0abeb5 --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.req.gql.g.dart @@ -0,0 +1,171 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'nested_fragments.req.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gTestQuerySerializer = new _$GTestQuerySerializer(); + +class _$GTestQuerySerializer implements StructuredSerializer { + @override + final Iterable types = const [GTestQuery, _$GTestQuery]; + @override + final String wireName = 'GTestQuery'; + + @override + Iterable serialize(Serializers serializers, GTestQuery object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + 'vars', + serializers.serialize(object.vars, + specifiedType: const FullType(_i3.GTestQueryVars)), + 'operation', + serializers.serialize(object.operation, + specifiedType: const FullType(_i1.Operation)), + ]; + + return result; + } + + @override + GTestQuery deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GTestQueryBuilder(); + + 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.GTestQueryVars))! + as _i3.GTestQueryVars); + break; + case 'operation': + result.operation = serializers.deserialize(value, + specifiedType: const FullType(_i1.Operation))! as _i1.Operation; + break; + } + } + + return result.build(); + } +} + +class _$GTestQuery extends GTestQuery { + @override + final _i3.GTestQueryVars vars; + @override + final _i1.Operation operation; + + factory _$GTestQuery([void Function(GTestQueryBuilder)? updates]) => + (new GTestQueryBuilder()..update(updates))._build(); + + _$GTestQuery._({required this.vars, required this.operation}) : super._() { + BuiltValueNullFieldError.checkNotNull(vars, r'GTestQuery', 'vars'); + BuiltValueNullFieldError.checkNotNull( + operation, r'GTestQuery', 'operation'); + } + + @override + GTestQuery rebuild(void Function(GTestQueryBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GTestQueryBuilder toBuilder() => new GTestQueryBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GTestQuery && + 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'GTestQuery') + ..add('vars', vars) + ..add('operation', operation)) + .toString(); + } +} + +class GTestQueryBuilder implements Builder { + _$GTestQuery? _$v; + + _i3.GTestQueryVarsBuilder? _vars; + _i3.GTestQueryVarsBuilder get vars => + _$this._vars ??= new _i3.GTestQueryVarsBuilder(); + set vars(_i3.GTestQueryVarsBuilder? vars) => _$this._vars = vars; + + _i1.Operation? _operation; + _i1.Operation? get operation => _$this._operation; + set operation(_i1.Operation? operation) => _$this._operation = operation; + + GTestQueryBuilder() { + GTestQuery._initializeBuilder(this); + } + + GTestQueryBuilder get _$this { + final $v = _$v; + if ($v != null) { + _vars = $v.vars.toBuilder(); + _operation = $v.operation; + _$v = null; + } + return this; + } + + @override + void replace(GTestQuery other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GTestQuery; + } + + @override + void update(void Function(GTestQueryBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GTestQuery build() => _build(); + + _$GTestQuery _build() { + _$GTestQuery _$result; + try { + _$result = _$v ?? + new _$GTestQuery._( + vars: vars.build(), + operation: BuiltValueNullFieldError.checkNotNull( + operation, r'GTestQuery', 'operation')); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'vars'; + vars.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GTestQuery', _$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/fragments/__generated__/nested_fragments.var.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.var.gql.dart new file mode 100644 index 00000000..eb1e4ff2 --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.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/graphql/__generated__/serializers.gql.dart' + as _i1; + +part 'nested_fragments.var.gql.g.dart'; + +abstract class GTestQueryVars + implements Built { + GTestQueryVars._(); + + factory GTestQueryVars([void Function(GTestQueryVarsBuilder b) updates]) = + _$GTestQueryVars; + + static Serializer get serializer => + _$gTestQueryVarsSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GTestQueryVars.serializer, + this, + ) as Map); + + static GTestQueryVars? fromJson(Map json) => + _i1.serializers.deserializeWith( + GTestQueryVars.serializer, + json, + ); +} + +abstract class GUserFragmentVars + implements Built { + GUserFragmentVars._(); + + factory GUserFragmentVars( + [void Function(GUserFragmentVarsBuilder b) updates]) = + _$GUserFragmentVars; + + static Serializer get serializer => + _$gUserFragmentVarsSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GUserFragmentVars.serializer, + this, + ) as Map); + + static GUserFragmentVars? fromJson(Map json) => + _i1.serializers.deserializeWith( + GUserFragmentVars.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.var.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.var.gql.g.dart new file mode 100644 index 00000000..b084854d --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.var.gql.g.dart @@ -0,0 +1,173 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'nested_fragments.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gTestQueryVarsSerializer = + new _$GTestQueryVarsSerializer(); +Serializer _$gUserFragmentVarsSerializer = + new _$GUserFragmentVarsSerializer(); + +class _$GTestQueryVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GTestQueryVars, _$GTestQueryVars]; + @override + final String wireName = 'GTestQueryVars'; + + @override + Iterable serialize(Serializers serializers, GTestQueryVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GTestQueryVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GTestQueryVarsBuilder().build(); + } +} + +class _$GUserFragmentVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GUserFragmentVars, _$GUserFragmentVars]; + @override + final String wireName = 'GUserFragmentVars'; + + @override + Iterable serialize(Serializers serializers, GUserFragmentVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GUserFragmentVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GUserFragmentVarsBuilder().build(); + } +} + +class _$GTestQueryVars extends GTestQueryVars { + factory _$GTestQueryVars([void Function(GTestQueryVarsBuilder)? updates]) => + (new GTestQueryVarsBuilder()..update(updates))._build(); + + _$GTestQueryVars._() : super._(); + + @override + GTestQueryVars rebuild(void Function(GTestQueryVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GTestQueryVarsBuilder toBuilder() => + new GTestQueryVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GTestQueryVars; + } + + @override + int get hashCode { + return 546902809; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GTestQueryVars').toString(); + } +} + +class GTestQueryVarsBuilder + implements Builder { + _$GTestQueryVars? _$v; + + GTestQueryVarsBuilder(); + + @override + void replace(GTestQueryVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GTestQueryVars; + } + + @override + void update(void Function(GTestQueryVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GTestQueryVars build() => _build(); + + _$GTestQueryVars _build() { + final _$result = _$v ?? new _$GTestQueryVars._(); + replace(_$result); + return _$result; + } +} + +class _$GUserFragmentVars extends GUserFragmentVars { + factory _$GUserFragmentVars( + [void Function(GUserFragmentVarsBuilder)? updates]) => + (new GUserFragmentVarsBuilder()..update(updates))._build(); + + _$GUserFragmentVars._() : super._(); + + @override + GUserFragmentVars rebuild(void Function(GUserFragmentVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GUserFragmentVarsBuilder toBuilder() => + new GUserFragmentVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GUserFragmentVars; + } + + @override + int get hashCode { + return 203572066; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GUserFragmentVars').toString(); + } +} + +class GUserFragmentVarsBuilder + implements Builder { + _$GUserFragmentVars? _$v; + + GUserFragmentVarsBuilder(); + + @override + void replace(GUserFragmentVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GUserFragmentVars; + } + + @override + void update(void Function(GUserFragmentVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GUserFragmentVars build() => _build(); + + _$GUserFragmentVars _build() { + final _$result = _$v ?? new _$GUserFragmentVars._(); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/fragments/nested_fragments.graphql b/codegen/end_to_end_test/lib/fragments/nested_fragments.graphql new file mode 100644 index 00000000..2e2a708f --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/nested_fragments.graphql @@ -0,0 +1,28 @@ + +query TestQuery { + currentUser { + ...UserFragment + } + + currentUser2: currentUser { + ...UserFragment + location { + lat + lng + } + moderation { + moderationStatus + } + } +} + +fragment UserFragment on User { + id + location { + lat + lng + } + moderation { + moderationStatus + } +} \ No newline at end of file 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 3b75b47a..ce044936 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 @@ -214,6 +214,15 @@ const Query = _i1.ObjectTypeDefinitionNode( isNonNull: false, ), ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'currentUser'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'User'), + isNonNull: false, + ), + ), ], ); const Mutation = _i1.ObjectTypeDefinitionNode( @@ -1085,6 +1094,99 @@ const PostFavorites = _i1.ObjectTypeDefinitionNode( ) ], ); +const User = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'User'), + 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: 'location'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Location'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'moderation'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Moderation'), + isNonNull: false, + ), + ), + ], +); +const Location = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'Location'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'lat'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Float'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'lng'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Float'), + isNonNull: true, + ), + ), + ], +); +const Moderation = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'Moderation'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'moderationStatus'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ModerationStatus'), + isNonNull: true, + ), + ) + ], +); +const ModerationStatus = _i1.EnumTypeDefinitionNode( + name: _i1.NameNode(value: 'ModerationStatus'), + directives: [], + values: [ + _i1.EnumValueDefinitionNode( + name: _i1.NameNode(value: 'APPROVED'), + directives: [], + ), + _i1.EnumValueDefinitionNode( + name: _i1.NameNode(value: 'REJECTED'), + directives: [], + ), + _i1.EnumValueDefinitionNode( + name: _i1.NameNode(value: 'PENDING'), + directives: [], + ), + ], +); const PostLikesInput = _i1.InputObjectTypeDefinitionNode( name: _i1.NameNode(value: 'PostLikesInput'), directives: [], @@ -1171,6 +1273,10 @@ const document = _i1.DocumentNode(definitions: [ Post, PostLikes, PostFavorites, + User, + Location, + Moderation, + ModerationStatus, PostLikesInput, PostFavoritesInput, 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 a5e5943a..f69ceb14 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 @@ -120,6 +120,24 @@ abstract class GColorInput implements Built { ); } +class GModerationStatus extends EnumClass { + const GModerationStatus._(String name) : super(name); + + static const GModerationStatus APPROVED = _$gModerationStatusAPPROVED; + + static const GModerationStatus REJECTED = _$gModerationStatusREJECTED; + + static const GModerationStatus PENDING = _$gModerationStatusPENDING; + + static Serializer get serializer => + _$gModerationStatusSerializer; + + static BuiltSet get values => _$gModerationStatusValues; + + static GModerationStatus valueOf(String name) => + _$gModerationStatusValueOf(name); +} + abstract class GPostLikesInput implements Built { GPostLikesInput._(); 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 ec9b81b6..2f22289e 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 @@ -50,6 +50,33 @@ final BuiltSet _$gLengthUnitValues = _$gLengthUnitFOOT, ]); +const GModerationStatus _$gModerationStatusAPPROVED = + const GModerationStatus._('APPROVED'); +const GModerationStatus _$gModerationStatusREJECTED = + const GModerationStatus._('REJECTED'); +const GModerationStatus _$gModerationStatusPENDING = + const GModerationStatus._('PENDING'); + +GModerationStatus _$gModerationStatusValueOf(String name) { + switch (name) { + case 'APPROVED': + return _$gModerationStatusAPPROVED; + case 'REJECTED': + return _$gModerationStatusREJECTED; + case 'PENDING': + return _$gModerationStatusPENDING; + default: + throw new ArgumentError(name); + } +} + +final BuiltSet _$gModerationStatusValues = + new BuiltSet(const [ + _$gModerationStatusAPPROVED, + _$gModerationStatusREJECTED, + _$gModerationStatusPENDING, +]); + Serializer _$gEpisodeSerializer = new _$GEpisodeSerializer(); Serializer _$gLengthUnitSerializer = new _$GLengthUnitSerializer(); Serializer _$gReviewInputSerializer = @@ -57,6 +84,8 @@ Serializer _$gReviewInputSerializer = Serializer _$gCustomFieldInputSerializer = new _$GCustomFieldInputSerializer(); Serializer _$gColorInputSerializer = new _$GColorInputSerializer(); +Serializer _$gModerationStatusSerializer = + new _$GModerationStatusSerializer(); Serializer _$gPostLikesInputSerializer = new _$GPostLikesInputSerializer(); Serializer _$gPostFavoritesInputSerializer = @@ -284,6 +313,24 @@ class _$GColorInputSerializer implements StructuredSerializer { } } +class _$GModerationStatusSerializer + implements PrimitiveSerializer { + @override + final Iterable types = const [GModerationStatus]; + @override + final String wireName = 'GModerationStatus'; + + @override + Object serialize(Serializers serializers, GModerationStatus object, + {FullType specifiedType = FullType.unspecified}) => + object.name; + + @override + GModerationStatus deserialize(Serializers serializers, Object serialized, + {FullType specifiedType = FullType.unspecified}) => + GModerationStatus.valueOf(serialized as String); +} + class _$GPostLikesInputSerializer implements StructuredSerializer { @override 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 8b1a78bc..7782f836 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 @@ -85,6 +85,16 @@ import 'package:end_to_end_test/fragments/__generated__/multiple_fragments.req.g show GHeroWith2Fragments; import 'package:end_to_end_test/fragments/__generated__/multiple_fragments.var.gql.dart' show GHeroWith2FragmentsVars, GheroIdVars, GheroNameVars; +import 'package:end_to_end_test/fragments/__generated__/nested_fragments.data.gql.dart' + show + GTestQueryData, + GUserFragmentData, + GUserFragmentData_location, + GUserFragmentData_moderation; +import 'package:end_to_end_test/fragments/__generated__/nested_fragments.req.gql.dart' + show GTestQuery; +import 'package:end_to_end_test/fragments/__generated__/nested_fragments.var.gql.dart' + show GTestQueryVars, GUserFragmentVars; import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart' show GColorInput, @@ -93,6 +103,7 @@ import 'package:end_to_end_test/graphql/__generated__/schema.schema.gql.dart' GISODate, GJson, GLengthUnit, + GModerationStatus, GPostFavoritesInput, GPostLikesInput, GReviewInput; @@ -200,6 +211,7 @@ final SerializersBuilder _serializersBuilder = _$serializers.toBuilder() GISODate, GJson, GLengthUnit, + GModerationStatus, GPostFavoritesInput, GPostFragmentData, GPostFragmentData_isFavorited, @@ -223,6 +235,13 @@ final SerializersBuilder _serializersBuilder = _$serializers.toBuilder() GReviewWithDateData, GReviewWithDateData_createReview, GReviewWithDateVars, + GTestQuery, + GTestQueryData, + GTestQueryVars, + GUserFragmentData, + GUserFragmentData_location, + GUserFragmentData_moderation, + GUserFragmentVars, GcomparisonFieldsData, GcomparisonFieldsData_friendsConnection, GcomparisonFieldsData_friendsConnection_edges, 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 a6594e80..6fadcf86 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 @@ -53,6 +53,7 @@ Serializers _$serializers = (new Serializers().toBuilder() ..add(GISODate.serializer) ..add(GJson.serializer) ..add(GLengthUnit.serializer) + ..add(GModerationStatus.serializer) ..add(GPostFavoritesInput.serializer) ..add(GPostFragmentData.serializer) ..add(GPostFragmentData_isFavorited.serializer) @@ -76,6 +77,13 @@ Serializers _$serializers = (new Serializers().toBuilder() ..add(GReviewWithDateData.serializer) ..add(GReviewWithDateData_createReview.serializer) ..add(GReviewWithDateVars.serializer) + ..add(GTestQuery.serializer) + ..add(GTestQueryData.serializer) + ..add(GTestQueryVars.serializer) + ..add(GUserFragmentData.serializer) + ..add(GUserFragmentData_location.serializer) + ..add(GUserFragmentData_moderation.serializer) + ..add(GUserFragmentVars.serializer) ..add(GcomparisonFieldsData.serializer) ..add(GcomparisonFieldsData_friendsConnection.serializer) ..add(GcomparisonFieldsData_friendsConnection_edges.serializer) diff --git a/codegen/end_to_end_test/lib/graphql/schema.graphql b/codegen/end_to_end_test/lib/graphql/schema.graphql index 671605a7..b51a2919 100644 --- a/codegen/end_to_end_test/lib/graphql/schema.graphql +++ b/codegen/end_to_end_test/lib/graphql/schema.graphql @@ -19,6 +19,7 @@ type Query { human(id: ID!): Human starship(id: ID!): Starship posts(userId: ID!, filter: Json): [Post] + currentUser: User } # The mutation type, represents all updates we can make to our data @@ -196,6 +197,28 @@ type PostFavorites { totalCount: Int! } +type User { + id: ID! + location: Location + moderation: Moderation +} + +type Location { + lat: Float! + lng: Float! +} + +type Moderation { + moderationStatus: ModerationStatus! +} + +enum ModerationStatus { + APPROVED + REJECTED + PENDING +} + + input PostLikesInput { id: ID! } From ad829368255bcf3fa02080af32019e255e3c3923 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 7 Jan 2024 05:27:59 +0000 Subject: [PATCH 04/12] simpler version of reuse fragments with less scope --- codegen/end_to_end_test/pubspec.yaml | 39 -------- codegen/gql_code_builder/lib/data.dart | 33 ++++--- codegen/gql_code_builder/lib/src/common.dart | 9 +- .../lib/src/inline_fragment_classes.dart | 4 + .../lib/src/operation/data.dart | 88 ++++++++++++++++++- 5 files changed, 116 insertions(+), 57 deletions(-) diff --git a/codegen/end_to_end_test/pubspec.yaml b/codegen/end_to_end_test/pubspec.yaml index 886e4976..a44d3a61 100644 --- a/codegen/end_to_end_test/pubspec.yaml +++ b/codegen/end_to_end_test/pubspec.yaml @@ -15,42 +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_tristate_value: - path: ../gql_tristate_value - 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 - end_to_end_test_tristate: - path: ../end_to_end_test_tristate diff --git a/codegen/gql_code_builder/lib/data.dart b/codegen/gql_code_builder/lib/data.dart index b64d6607..fe1efe57 100644 --- a/codegen/gql_code_builder/lib/data.dart +++ b/codegen/gql_code_builder/lib/data.dart @@ -19,28 +19,35 @@ Library buildDataLibrary( generateMaybeWhenExtensionMethod: false, ), ]) { - final operationDataClasses = docSource.document.definitions - .whereType() - .expand( - (op) => buildOperationDataClasses( - op, - docSource, - schemaSource, - typeOverrides, - whenExtensionConfig, - ), - ) - .toList(); + + final fragmentRefMap = , Reference>{}; + final fragmentDataClasses = docSource.document.definitions .whereType() .expand( (frag) => buildFragmentDataClasses( - frag, + frag, + docSource, + schemaSource, + typeOverrides, + whenExtensionConfig, fragmentRefMap, + ), + ) + .toList(); + + + + final operationDataClasses = docSource.document.definitions + .whereType() + .expand( + (op) => buildOperationDataClasses( + op, docSource, schemaSource, typeOverrides, whenExtensionConfig, + fragmentRefMap, ), ) .toList(); diff --git a/codegen/gql_code_builder/lib/src/common.dart b/codegen/gql_code_builder/lib/src/common.dart index 77e6168b..e3756567 100644 --- a/codegen/gql_code_builder/lib/src/common.dart +++ b/codegen/gql_code_builder/lib/src/common.dart @@ -138,6 +138,7 @@ Method buildGetter({ required TypeNode typeNode, required SourceNode schemaSource, Map typeOverrides = const {}, + Reference? fragmentRef, String? typeRefPrefix, bool built = true, bool isOverride = false, @@ -161,10 +162,10 @@ Method buildGetter({ ...typeOverrides, }; - final returnType = _typeRef( - typeNode, - typeMap, - ); + final returnType = fragmentRef ?? _typeRef( + typeNode, + typeMap, + ); return Method( (b) => b diff --git a/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart b/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart index cb49a696..27e1b11a 100644 --- a/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart +++ b/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart @@ -1,3 +1,4 @@ +import "package:built_collection/built_collection.dart"; import "package:code_builder/code_builder.dart"; import "package:gql/ast.dart"; import "package:gql_code_builder/src/config/when_extension_config.dart"; @@ -26,6 +27,7 @@ List buildInlineFragmentClasses({ required List inlineFragments, required bool built, required InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig, + required Map, Reference> fragmentRefMap, }) { final whenExtension = inlineFragmentWhenExtension( baseTypeName: name, @@ -73,6 +75,7 @@ List buildInlineFragmentClasses({ }, built: built, whenExtensionConfig: whenExtensionConfig, + fragmentRefMap: fragmentRefMap, ), /// TODO: Handle inline fragments without a type condition @@ -96,6 +99,7 @@ List buildInlineFragmentClasses({ name: SourceSelections(url: null, selections: selections) }, built: built, + fragmentRefMap: fragmentRefMap, whenExtensionConfig: whenExtensionConfig), ), ]; diff --git a/codegen/gql_code_builder/lib/src/operation/data.dart b/codegen/gql_code_builder/lib/src/operation/data.dart index 490ccf53..694303b9 100644 --- a/codegen/gql_code_builder/lib/src/operation/data.dart +++ b/codegen/gql_code_builder/lib/src/operation/data.dart @@ -1,4 +1,6 @@ +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/src/config/when_extension_config.dart"; @@ -13,6 +15,7 @@ List buildOperationDataClasses( SourceNode schemaSource, Map typeOverrides, InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig, + Map, Reference> fragmentRefMap, ) { if (op.name == null) { throw Exception("Operations must be named"); @@ -34,6 +37,7 @@ List buildOperationDataClasses( fragmentMap: fragmentMap, superclassSelections: {}, whenExtensionConfig: whenExtensionConfig, + fragmentRefMap: fragmentRefMap, ); } @@ -43,12 +47,25 @@ List buildFragmentDataClasses( SourceNode schemaSource, Map typeOverrides, InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig, + Map, Reference> fragmentRefMap, ) { final fragmentMap = _fragmentMap(docSource); final selections = mergeSelections( frag.selectionSet.selections, fragmentMap, ); + + final set = BuiltSet.of(selections.withoutFragmentSpreads); + + if(fragmentRefMap.containsKey(set)){ + print("***** warning: duplicated fragment found: ${frag.name.value} in ${docSource.url}, previous defintion with same data ${fragmentRefMap[set]}"); + } + + fragmentRefMap[set] = refer( + builtClassName("${frag.name.value}Data"), + (docSource.url ?? "") + "#data", + ); + return [ // abstract class that will implemented by any class that uses the fragment ...buildSelectionSetDataClasses( @@ -61,6 +78,7 @@ List buildFragmentDataClasses( superclassSelections: {}, built: false, whenExtensionConfig: whenExtensionConfig, + fragmentRefMap: fragmentRefMap, ), // concrete built_value data class for fragment ...buildSelectionSetDataClasses( @@ -77,6 +95,7 @@ List buildFragmentDataClasses( ) }, whenExtensionConfig: whenExtensionConfig, + fragmentRefMap: fragmentRefMap, ), ]; } @@ -127,6 +146,7 @@ List buildSelectionSetDataClasses({ required Map superclassSelections, bool built = true, required InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig, + required Map, Reference> fragmentRefMap, }) { for (final selection in selections.whereType()) { if (!fragmentMap.containsKey(selection.name.value)) { @@ -146,6 +166,8 @@ List buildSelectionSetDataClasses({ .expand((selections) => selections.selections) .toSet(); + final fieldsThatAreSingleFragmentSpreads = {}; + final fieldGetters = selections.whereType().map( (node) { final nameNode = node.alias ?? node.name; @@ -157,11 +179,30 @@ List buildSelectionSetDataClasses({ typeDef, node.name.value, ); + + final getterSelections = node.selectionSet; + + Reference? fragmentRef; + + if(getterSelections != null){ + final withoutFragmentSpreads = getterSelections.selections.withoutFragmentSpreads.toBuiltSet(); + + final hasMatchingFragment = fragmentRefMap[withoutFragmentSpreads]; + + if(hasMatchingFragment != null){ + fieldsThatAreSingleFragmentSpreads.add(node); + } + + fragmentRef = hasMatchingFragment; + + } + return buildGetter( nameNode: nameNode, typeNode: typeNode, schemaSource: schemaSource, typeOverrides: typeOverrides, + fragmentRef: fragmentRef, typeRefPrefix: node.selectionSet != null ? builtClassName(name) : null, built: built, isOverride: superclassSelectionNodes.contains(node), @@ -185,6 +226,7 @@ List buildSelectionSetDataClasses({ inlineFragments: inlineFragments, built: built, whenExtensionConfig: whenExtensionConfig, + fragmentRefMap: fragmentRefMap, ) else if (!built) Class( @@ -222,7 +264,7 @@ List buildSelectionSetDataClasses({ ...selections .whereType() .where( - (field) => field.selectionSet != null, + (field) => field.selectionSet != null && !fieldsThatAreSingleFragmentSpreads.contains(field), ) .expand( (field) => buildSelectionSetDataClasses( @@ -246,6 +288,7 @@ List buildSelectionSetDataClasses({ ), built: inlineFragments.isNotEmpty ? false : built, whenExtensionConfig: whenExtensionConfig, + fragmentRefMap: fragmentRefMap, ), ), ]; @@ -379,3 +422,46 @@ TypeNode _getFieldTypeNode( ) .type; } + +extension IsSingleFragmentSpread on SelectionSetNode { + + Iterable get withoutTypeName => selections.where((selection) => selection is! FieldNode || selection.name.value != "__typename"); + + bool get isSingleFragmentSpread => withoutTypeName.length == 1 && withoutTypeName.first is FragmentSpreadNode; + + Iterable get fragmentSpreads => selections.whereType(); + + Iterable get inlineFragments => selections.whereType(); + + Iterable get fields => selections.whereType(); + + + } + + extension WithoutFragmentSpreads on Iterable { + Iterable get withoutFragmentSpreads => where((selection) => selection is! FragmentSpreadNode) + .map((e) { + if(e is FieldNode){ + if(e.selectionSet == null) return e; + return FieldNode( + name: e.name, + alias: e.alias, + arguments: e.arguments, + directives: e.directives, + selectionSet: SelectionSetNode( + selections: e.selectionSet!.selections.withoutFragmentSpreads.toList(), + ), + ); + } + if(e is InlineFragmentNode){ + return InlineFragmentNode( + typeCondition: e.typeCondition, + directives: e.directives, + selectionSet: SelectionSetNode( + selections: e.selectionSet.selections.withoutFragmentSpreads.toList(), + ), + ); + } + return e; + }); + } From eedf28014316c1c62c638817b7d3a1a9397db325 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 7 Jan 2024 14:04:53 +0000 Subject: [PATCH 05/12] fmt --- codegen/gql_code_builder/lib/data.dart | 19 ++-- codegen/gql_code_builder/lib/src/common.dart | 9 +- .../lib/src/operation/data.dart | 99 ++++++++++--------- 3 files changed, 66 insertions(+), 61 deletions(-) diff --git a/codegen/gql_code_builder/lib/data.dart b/codegen/gql_code_builder/lib/data.dart index fe1efe57..350db1f1 100644 --- a/codegen/gql_code_builder/lib/data.dart +++ b/codegen/gql_code_builder/lib/data.dart @@ -19,25 +19,22 @@ Library buildDataLibrary( generateMaybeWhenExtensionMethod: false, ), ]) { - final fragmentRefMap = , Reference>{}; - final fragmentDataClasses = docSource.document.definitions .whereType() .expand( (frag) => buildFragmentDataClasses( - frag, - docSource, - schemaSource, - typeOverrides, - whenExtensionConfig, fragmentRefMap, - ), - ) + frag, + docSource, + schemaSource, + typeOverrides, + whenExtensionConfig, + fragmentRefMap, + ), + ) .toList(); - - final operationDataClasses = docSource.document.definitions .whereType() .expand( diff --git a/codegen/gql_code_builder/lib/src/common.dart b/codegen/gql_code_builder/lib/src/common.dart index e3756567..fbfb9a49 100644 --- a/codegen/gql_code_builder/lib/src/common.dart +++ b/codegen/gql_code_builder/lib/src/common.dart @@ -162,10 +162,11 @@ Method buildGetter({ ...typeOverrides, }; - final returnType = fragmentRef ?? _typeRef( - typeNode, - typeMap, - ); + final returnType = fragmentRef ?? + _typeRef( + typeNode, + typeMap, + ); return Method( (b) => b diff --git a/codegen/gql_code_builder/lib/src/operation/data.dart b/codegen/gql_code_builder/lib/src/operation/data.dart index 694303b9..aef8bc40 100644 --- a/codegen/gql_code_builder/lib/src/operation/data.dart +++ b/codegen/gql_code_builder/lib/src/operation/data.dart @@ -15,7 +15,7 @@ List buildOperationDataClasses( SourceNode schemaSource, Map typeOverrides, InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig, - Map, Reference> fragmentRefMap, + Map, Reference> fragmentRefMap, ) { if (op.name == null) { throw Exception("Operations must be named"); @@ -57,8 +57,9 @@ List buildFragmentDataClasses( final set = BuiltSet.of(selections.withoutFragmentSpreads); - if(fragmentRefMap.containsKey(set)){ - print("***** warning: duplicated fragment found: ${frag.name.value} in ${docSource.url}, previous defintion with same data ${fragmentRefMap[set]}"); + if (fragmentRefMap.containsKey(set)) { + print( + "***** warning: duplicated fragment found: ${frag.name.value} in ${docSource.url}, previous defintion with same data ${fragmentRefMap[set]}"); } fragmentRefMap[set] = refer( @@ -78,7 +79,7 @@ List buildFragmentDataClasses( superclassSelections: {}, built: false, whenExtensionConfig: whenExtensionConfig, - fragmentRefMap: fragmentRefMap, + fragmentRefMap: fragmentRefMap, ), // concrete built_value data class for fragment ...buildSelectionSetDataClasses( @@ -95,7 +96,7 @@ List buildFragmentDataClasses( ) }, whenExtensionConfig: whenExtensionConfig, - fragmentRefMap: fragmentRefMap, + fragmentRefMap: fragmentRefMap, ), ]; } @@ -184,17 +185,17 @@ List buildSelectionSetDataClasses({ Reference? fragmentRef; - if(getterSelections != null){ - final withoutFragmentSpreads = getterSelections.selections.withoutFragmentSpreads.toBuiltSet(); + if (getterSelections != null) { + final withoutFragmentSpreads = + getterSelections.selections.withoutFragmentSpreads.toBuiltSet(); final hasMatchingFragment = fragmentRefMap[withoutFragmentSpreads]; - if(hasMatchingFragment != null){ + if (hasMatchingFragment != null) { fieldsThatAreSingleFragmentSpreads.add(node); } fragmentRef = hasMatchingFragment; - } return buildGetter( @@ -264,7 +265,9 @@ List buildSelectionSetDataClasses({ ...selections .whereType() .where( - (field) => field.selectionSet != null && !fieldsThatAreSingleFragmentSpreads.contains(field), + (field) => + field.selectionSet != null && + !fieldsThatAreSingleFragmentSpreads.contains(field), ) .expand( (field) => buildSelectionSetDataClasses( @@ -288,7 +291,7 @@ List buildSelectionSetDataClasses({ ), built: inlineFragments.isNotEmpty ? false : built, whenExtensionConfig: whenExtensionConfig, - fragmentRefMap: fragmentRefMap, + fragmentRefMap: fragmentRefMap, ), ), ]; @@ -424,44 +427,48 @@ TypeNode _getFieldTypeNode( } extension IsSingleFragmentSpread on SelectionSetNode { + Iterable get withoutTypeName => selections.where((selection) => + selection is! FieldNode || selection.name.value != "__typename"); - Iterable get withoutTypeName => selections.where((selection) => selection is! FieldNode || selection.name.value != "__typename"); - - bool get isSingleFragmentSpread => withoutTypeName.length == 1 && withoutTypeName.first is FragmentSpreadNode; + bool get isSingleFragmentSpread => + withoutTypeName.length == 1 && + withoutTypeName.first is FragmentSpreadNode; - Iterable get fragmentSpreads => selections.whereType(); + Iterable get fragmentSpreads => + selections.whereType(); - Iterable get inlineFragments => selections.whereType(); + Iterable get inlineFragments => + selections.whereType(); Iterable get fields => selections.whereType(); +} - - } - - extension WithoutFragmentSpreads on Iterable { - Iterable get withoutFragmentSpreads => where((selection) => selection is! FragmentSpreadNode) - .map((e) { - if(e is FieldNode){ - if(e.selectionSet == null) return e; - return FieldNode( - name: e.name, - alias: e.alias, - arguments: e.arguments, - directives: e.directives, - selectionSet: SelectionSetNode( - selections: e.selectionSet!.selections.withoutFragmentSpreads.toList(), - ), - ); - } - if(e is InlineFragmentNode){ - return InlineFragmentNode( - typeCondition: e.typeCondition, - directives: e.directives, - selectionSet: SelectionSetNode( - selections: e.selectionSet.selections.withoutFragmentSpreads.toList(), - ), - ); - } - return e; - }); - } +extension WithoutFragmentSpreads on Iterable { + Iterable get withoutFragmentSpreads => + where((selection) => selection is! FragmentSpreadNode).map((e) { + if (e is FieldNode) { + if (e.selectionSet == null) return e; + return FieldNode( + name: e.name, + alias: e.alias, + arguments: e.arguments, + directives: e.directives, + selectionSet: SelectionSetNode( + selections: + e.selectionSet!.selections.withoutFragmentSpreads.toList(), + ), + ); + } + if (e is InlineFragmentNode) { + return InlineFragmentNode( + typeCondition: e.typeCondition, + directives: e.directives, + selectionSet: SelectionSetNode( + selections: + e.selectionSet.selections.withoutFragmentSpreads.toList(), + ), + ); + } + return e; + }); +} From f24cc1a8a943bce174592af6dc34831fb88d75ca Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 7 Jan 2024 14:43:55 +0000 Subject: [PATCH 06/12] fix ommiting list when reused fragment is in a list --- .../alias_var_fragment.data.gql.dart | 3 +- .../alias_var_fragment.data.gql.g.dart | 37 +++++++------- .../fragment_with_scalar_var.data.gql.dart | 3 +- .../fragment_with_scalar_var.data.gql.g.dart | 40 +++++++++------- .../hero_with_fragments.data.gql.dart | 6 +-- .../hero_with_fragments.data.gql.g.dart | 48 ++++++++++--------- .../nested_fragments.data.gql.dart | 4 +- .../nested_fragments.data.gql.g.dart | 46 +++++++++--------- .../__generated__/serializers.gql.g.dart | 8 ++++ codegen/end_to_end_test/pubspec.yaml | 39 +++++++++++++++ codegen/end_to_end_test_tristate/pubspec.yaml | 39 +++++++++++++++ codegen/gql_build/pubspec.yaml | 39 +++++++++++++++ codegen/gql_code_builder/lib/src/common.dart | 9 ++-- .../lib/src/operation/data.dart | 9 +++- codegen/gql_code_builder/pubspec.yaml | 39 +++++++++++++++ codegen/gql_tristate_value/pubspec.yaml | 39 +++++++++++++++ examples/gql_example_build/pubspec.yaml | 39 +++++++++++++++ examples/gql_example_cli/pubspec.yaml | 39 +++++++++++++++ examples/gql_example_cli_github/pubspec.yaml | 39 +++++++++++++++ examples/gql_example_dio_link/pubspec.yaml | 39 +++++++++++++++ examples/gql_example_flutter/pubspec.yaml | 41 ++++++++++++++++ .../gql_example_http_auth_link/pubspec.yaml | 39 +++++++++++++++ gql/pubspec.yaml | 39 +++++++++++++++ gql_pedantic/pubspec.yaml | 39 +++++++++++++++ links/gql_dedupe_link/pubspec.yaml | 39 +++++++++++++++ links/gql_dio_link/pubspec.yaml | 39 +++++++++++++++ links/gql_error_link/pubspec.yaml | 39 +++++++++++++++ links/gql_exec/pubspec.yaml | 39 +++++++++++++++ links/gql_http_link/pubspec.yaml | 39 +++++++++++++++ links/gql_link/pubspec.yaml | 39 +++++++++++++++ links/gql_transform_link/pubspec.yaml | 39 +++++++++++++++ links/gql_websocket_link/pubspec.yaml | 39 +++++++++++++++ 32 files changed, 943 insertions(+), 91 deletions(-) diff --git a/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.dart b/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.dart index 5e78a0dd..edc6354f 100644 --- a/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.dart +++ b/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.dart @@ -2,6 +2,7 @@ // 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/graphql/__generated__/serializers.gql.dart' @@ -20,7 +21,7 @@ abstract class GPostsData implements Built { @BuiltValueField(wireName: '__typename') String get G__typename; - GPostFragmentData get posts; + BuiltList? get posts; static Serializer get serializer => _$gPostsDataSerializer; Map toJson() => (_i1.serializers.serializeWith( diff --git a/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.g.dart b/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.g.dart index cb69b019..ef98fb84 100644 --- a/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.g.dart +++ b/codegen/end_to_end_test/lib/aliases/__generated__/alias_var_fragment.data.gql.g.dart @@ -28,11 +28,16 @@ class _$GPostsDataSerializer implements StructuredSerializer { '__typename', serializers.serialize(object.G__typename, specifiedType: const FullType(String)), - 'posts', - serializers.serialize(object.posts, - specifiedType: const FullType(GPostFragmentData)), ]; - + Object? value; + value = object.posts; + if (value != null) { + result + ..add('posts') + ..add(serializers.serialize(value, + specifiedType: const FullType(BuiltList, + const [const FullType.nullable(GPostFragmentData)]))); + } return result; } @@ -53,8 +58,9 @@ class _$GPostsDataSerializer implements StructuredSerializer { break; case 'posts': result.posts.replace(serializers.deserialize(value, - specifiedType: const FullType(GPostFragmentData))! - as GPostFragmentData); + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable(GPostFragmentData) + ]))! as BuiltList); break; } } @@ -245,15 +251,14 @@ class _$GPostsData extends GPostsData { @override final String G__typename; @override - final GPostFragmentData posts; + final BuiltList? posts; factory _$GPostsData([void Function(GPostsDataBuilder)? updates]) => (new GPostsDataBuilder()..update(updates))._build(); - _$GPostsData._({required this.G__typename, required this.posts}) : super._() { + _$GPostsData._({required this.G__typename, this.posts}) : super._() { BuiltValueNullFieldError.checkNotNull( G__typename, r'GPostsData', 'G__typename'); - BuiltValueNullFieldError.checkNotNull(posts, r'GPostsData', 'posts'); } @override @@ -296,10 +301,10 @@ class GPostsDataBuilder implements Builder { String? get G__typename => _$this._G__typename; set G__typename(String? G__typename) => _$this._G__typename = G__typename; - GPostFragmentDataBuilder? _posts; - GPostFragmentDataBuilder get posts => - _$this._posts ??= new GPostFragmentDataBuilder(); - set posts(GPostFragmentDataBuilder? posts) => _$this._posts = posts; + ListBuilder? _posts; + ListBuilder get posts => + _$this._posts ??= new ListBuilder(); + set posts(ListBuilder? posts) => _$this._posts = posts; GPostsDataBuilder() { GPostsData._initializeBuilder(this); @@ -309,7 +314,7 @@ class GPostsDataBuilder implements Builder { final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; - _posts = $v.posts.toBuilder(); + _posts = $v.posts?.toBuilder(); _$v = null; } return this; @@ -336,12 +341,12 @@ class GPostsDataBuilder implements Builder { new _$GPostsData._( G__typename: BuiltValueNullFieldError.checkNotNull( G__typename, r'GPostsData', 'G__typename'), - posts: posts.build()); + posts: _posts?.build()); } catch (_) { late String _$failedField; try { _$failedField = 'posts'; - posts.build(); + _posts?.build(); } catch (e) { throw new BuiltValueNestedFieldError( r'GPostsData', _$failedField, e.toString()); diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.dart index a6af8498..39df8875 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.dart @@ -2,6 +2,7 @@ // 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/graphql/__generated__/serializers.gql.dart' @@ -23,7 +24,7 @@ abstract class GPostsWithFixedVariableData @BuiltValueField(wireName: '__typename') String get G__typename; - GPostFragmentForUser2Data get posts; + BuiltList? get posts; static Serializer get serializer => _$gPostsWithFixedVariableDataSerializer; diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.g.dart index 91dcdf26..1e4a8335 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.g.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_with_scalar_var.data.gql.g.dart @@ -38,11 +38,16 @@ class _$GPostsWithFixedVariableDataSerializer '__typename', serializers.serialize(object.G__typename, specifiedType: const FullType(String)), - 'posts', - serializers.serialize(object.posts, - specifiedType: const FullType(GPostFragmentForUser2Data)), ]; - + Object? value; + value = object.posts; + if (value != null) { + result + ..add('posts') + ..add(serializers.serialize(value, + specifiedType: const FullType(BuiltList, + const [const FullType.nullable(GPostFragmentForUser2Data)]))); + } return result; } @@ -64,8 +69,9 @@ class _$GPostsWithFixedVariableDataSerializer break; case 'posts': result.posts.replace(serializers.deserialize(value, - specifiedType: const FullType(GPostFragmentForUser2Data))! - as GPostFragmentForUser2Data); + specifiedType: const FullType(BuiltList, const [ + const FullType.nullable(GPostFragmentForUser2Data) + ]))! as BuiltList); break; } } @@ -316,19 +322,16 @@ class _$GPostsWithFixedVariableData extends GPostsWithFixedVariableData { @override final String G__typename; @override - final GPostFragmentForUser2Data posts; + final BuiltList? posts; factory _$GPostsWithFixedVariableData( [void Function(GPostsWithFixedVariableDataBuilder)? updates]) => (new GPostsWithFixedVariableDataBuilder()..update(updates))._build(); - _$GPostsWithFixedVariableData._( - {required this.G__typename, required this.posts}) + _$GPostsWithFixedVariableData._({required this.G__typename, this.posts}) : super._() { BuiltValueNullFieldError.checkNotNull( G__typename, r'GPostsWithFixedVariableData', 'G__typename'); - BuiltValueNullFieldError.checkNotNull( - posts, r'GPostsWithFixedVariableData', 'posts'); } @override @@ -376,10 +379,11 @@ class GPostsWithFixedVariableDataBuilder String? get G__typename => _$this._G__typename; set G__typename(String? G__typename) => _$this._G__typename = G__typename; - GPostFragmentForUser2DataBuilder? _posts; - GPostFragmentForUser2DataBuilder get posts => - _$this._posts ??= new GPostFragmentForUser2DataBuilder(); - set posts(GPostFragmentForUser2DataBuilder? posts) => _$this._posts = posts; + ListBuilder? _posts; + ListBuilder get posts => + _$this._posts ??= new ListBuilder(); + set posts(ListBuilder? posts) => + _$this._posts = posts; GPostsWithFixedVariableDataBuilder() { GPostsWithFixedVariableData._initializeBuilder(this); @@ -389,7 +393,7 @@ class GPostsWithFixedVariableDataBuilder final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; - _posts = $v.posts.toBuilder(); + _posts = $v.posts?.toBuilder(); _$v = null; } return this; @@ -416,12 +420,12 @@ class GPostsWithFixedVariableDataBuilder new _$GPostsWithFixedVariableData._( G__typename: BuiltValueNullFieldError.checkNotNull( G__typename, r'GPostsWithFixedVariableData', 'G__typename'), - posts: posts.build()); + posts: _posts?.build()); } catch (_) { late String _$failedField; try { _$failedField = 'posts'; - posts.build(); + _posts?.build(); } catch (e) { throw new BuiltValueNestedFieldError( r'GPostsWithFixedVariableData', _$failedField, e.toString()); diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.data.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.data.gql.dart index b041b509..15b49fbe 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.data.gql.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_fragments.data.gql.dart @@ -23,7 +23,7 @@ abstract class GHeroWithFragmentsData @BuiltValueField(wireName: '__typename') String get G__typename; - GcomparisonFieldsData get hero; + GcomparisonFieldsData? get hero; static Serializer get serializer => _$gHeroWithFragmentsDataSerializer; @@ -95,7 +95,7 @@ abstract class GcomparisonFields_friendsConnection { abstract class GcomparisonFields_friendsConnection_edges { String get G__typename; - GheroDataData get node; + GheroDataData? get node; Map toJson(); } @@ -196,7 +196,7 @@ abstract class GcomparisonFieldsData_friendsConnection_edges @BuiltValueField(wireName: '__typename') String get G__typename; @override - GheroDataData get node; + GheroDataData? get node; static Serializer get serializer => _$gcomparisonFieldsDataFriendsConnectionEdgesSerializer; 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 d98b612d..f0764d9c 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 @@ -37,11 +37,15 @@ class _$GHeroWithFragmentsDataSerializer '__typename', serializers.serialize(object.G__typename, specifiedType: const FullType(String)), - 'hero', - serializers.serialize(object.hero, - specifiedType: const FullType(GcomparisonFieldsData)), ]; - + Object? value; + value = object.hero; + if (value != null) { + result + ..add('hero') + ..add(serializers.serialize(value, + specifiedType: const FullType(GcomparisonFieldsData))); + } return result; } @@ -280,11 +284,15 @@ class _$GcomparisonFieldsData_friendsConnection_edgesSerializer '__typename', serializers.serialize(object.G__typename, specifiedType: const FullType(String)), - 'node', - serializers.serialize(object.node, - specifiedType: const FullType(GheroDataData)), ]; - + Object? value; + value = object.node; + if (value != null) { + result + ..add('node') + ..add(serializers.serialize(value, + specifiedType: const FullType(GheroDataData))); + } return result; } @@ -319,18 +327,16 @@ class _$GHeroWithFragmentsData extends GHeroWithFragmentsData { @override final String G__typename; @override - final GcomparisonFieldsData hero; + final GcomparisonFieldsData? hero; factory _$GHeroWithFragmentsData( [void Function(GHeroWithFragmentsDataBuilder)? updates]) => (new GHeroWithFragmentsDataBuilder()..update(updates))._build(); - _$GHeroWithFragmentsData._({required this.G__typename, required this.hero}) + _$GHeroWithFragmentsData._({required this.G__typename, this.hero}) : super._() { BuiltValueNullFieldError.checkNotNull( G__typename, r'GHeroWithFragmentsData', 'G__typename'); - BuiltValueNullFieldError.checkNotNull( - hero, r'GHeroWithFragmentsData', 'hero'); } @override @@ -389,7 +395,7 @@ class GHeroWithFragmentsDataBuilder final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; - _hero = $v.hero.toBuilder(); + _hero = $v.hero?.toBuilder(); _$v = null; } return this; @@ -416,12 +422,12 @@ class GHeroWithFragmentsDataBuilder new _$GHeroWithFragmentsData._( G__typename: BuiltValueNullFieldError.checkNotNull( G__typename, r'GHeroWithFragmentsData', 'G__typename'), - hero: hero.build()); + hero: _hero?.build()); } catch (_) { late String _$failedField; try { _$failedField = 'hero'; - hero.build(); + _hero?.build(); } catch (e) { throw new BuiltValueNestedFieldError( r'GHeroWithFragmentsData', _$failedField, e.toString()); @@ -832,7 +838,7 @@ class _$GcomparisonFieldsData_friendsConnection_edges @override final String G__typename; @override - final GheroDataData node; + final GheroDataData? node; factory _$GcomparisonFieldsData_friendsConnection_edges( [void Function(GcomparisonFieldsData_friendsConnection_edgesBuilder)? @@ -842,12 +848,10 @@ class _$GcomparisonFieldsData_friendsConnection_edges ._build(); _$GcomparisonFieldsData_friendsConnection_edges._( - {required this.G__typename, required this.node}) + {required this.G__typename, this.node}) : super._() { BuiltValueNullFieldError.checkNotNull(G__typename, r'GcomparisonFieldsData_friendsConnection_edges', 'G__typename'); - BuiltValueNullFieldError.checkNotNull( - node, r'GcomparisonFieldsData_friendsConnection_edges', 'node'); } @override @@ -909,7 +913,7 @@ class GcomparisonFieldsData_friendsConnection_edgesBuilder final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; - _node = $v.node.toBuilder(); + _node = $v.node?.toBuilder(); _$v = null; } return this; @@ -940,12 +944,12 @@ class GcomparisonFieldsData_friendsConnection_edgesBuilder G__typename, r'GcomparisonFieldsData_friendsConnection_edges', 'G__typename'), - node: node.build()); + node: _node?.build()); } catch (_) { late String _$failedField; try { _$failedField = 'node'; - node.build(); + _node?.build(); } catch (e) { throw new BuiltValueNestedFieldError( r'GcomparisonFieldsData_friendsConnection_edges', diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.dart index 327f40f9..5f191672 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.dart @@ -23,8 +23,8 @@ abstract class GTestQueryData @BuiltValueField(wireName: '__typename') String get G__typename; - GUserFragmentData get currentUser; - GUserFragmentData get currentUser2; + GUserFragmentData? get currentUser; + GUserFragmentData? get currentUser2; static Serializer get serializer => _$gTestQueryDataSerializer; diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.g.dart index e8a20354..a4596883 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.g.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/nested_fragments.data.gql.g.dart @@ -30,14 +30,22 @@ class _$GTestQueryDataSerializer '__typename', serializers.serialize(object.G__typename, specifiedType: const FullType(String)), - 'currentUser', - serializers.serialize(object.currentUser, - specifiedType: const FullType(GUserFragmentData)), - 'currentUser2', - serializers.serialize(object.currentUser2, - specifiedType: const FullType(GUserFragmentData)), ]; - + Object? value; + value = object.currentUser; + if (value != null) { + result + ..add('currentUser') + ..add(serializers.serialize(value, + specifiedType: const FullType(GUserFragmentData))); + } + value = object.currentUser2; + if (value != null) { + result + ..add('currentUser2') + ..add(serializers.serialize(value, + specifiedType: const FullType(GUserFragmentData))); + } return result; } @@ -262,24 +270,18 @@ class _$GTestQueryData extends GTestQueryData { @override final String G__typename; @override - final GUserFragmentData currentUser; + final GUserFragmentData? currentUser; @override - final GUserFragmentData currentUser2; + final GUserFragmentData? currentUser2; factory _$GTestQueryData([void Function(GTestQueryDataBuilder)? updates]) => (new GTestQueryDataBuilder()..update(updates))._build(); _$GTestQueryData._( - {required this.G__typename, - required this.currentUser, - required this.currentUser2}) + {required this.G__typename, this.currentUser, this.currentUser2}) : super._() { BuiltValueNullFieldError.checkNotNull( G__typename, r'GTestQueryData', 'G__typename'); - BuiltValueNullFieldError.checkNotNull( - currentUser, r'GTestQueryData', 'currentUser'); - BuiltValueNullFieldError.checkNotNull( - currentUser2, r'GTestQueryData', 'currentUser2'); } @override @@ -347,8 +349,8 @@ class GTestQueryDataBuilder final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; - _currentUser = $v.currentUser.toBuilder(); - _currentUser2 = $v.currentUser2.toBuilder(); + _currentUser = $v.currentUser?.toBuilder(); + _currentUser2 = $v.currentUser2?.toBuilder(); _$v = null; } return this; @@ -375,15 +377,15 @@ class GTestQueryDataBuilder new _$GTestQueryData._( G__typename: BuiltValueNullFieldError.checkNotNull( G__typename, r'GTestQueryData', 'G__typename'), - currentUser: currentUser.build(), - currentUser2: currentUser2.build()); + currentUser: _currentUser?.build(), + currentUser2: _currentUser2?.build()); } catch (_) { late String _$failedField; try { _$failedField = 'currentUser'; - currentUser.build(); + _currentUser?.build(); _$failedField = 'currentUser2'; - currentUser2.build(); + _currentUser2?.build(); } catch (e) { throw new BuiltValueNestedFieldError( r'GTestQueryData', _$failedField, e.toString()); 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 6fadcf86..d4490de5 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 @@ -133,6 +133,14 @@ Serializers _$serializers = (new Serializers().toBuilder() const FullType.nullable(GHeroForEpisodeData_hero__base_friends) ]), () => new ListBuilder()) + ..addBuilderFactory( + const FullType( + BuiltList, const [const FullType.nullable(GPostFragmentData)]), + () => new ListBuilder()) + ..addBuilderFactory( + const FullType(BuiltList, + const [const FullType.nullable(GPostFragmentForUser2Data)]), + () => new ListBuilder()) ..addBuilderFactory( const FullType(BuiltList, const [ const FullType.nullable( diff --git a/codegen/end_to_end_test/pubspec.yaml b/codegen/end_to_end_test/pubspec.yaml index a44d3a61..886e4976 100644 --- a/codegen/end_to_end_test/pubspec.yaml +++ b/codegen/end_to_end_test/pubspec.yaml @@ -15,3 +15,42 @@ 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_tristate_value: + path: ../gql_tristate_value + 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 + end_to_end_test_tristate: + path: ../end_to_end_test_tristate diff --git a/codegen/end_to_end_test_tristate/pubspec.yaml b/codegen/end_to_end_test_tristate/pubspec.yaml index 9da7f779..fb70ee02 100644 --- a/codegen/end_to_end_test_tristate/pubspec.yaml +++ b/codegen/end_to_end_test_tristate/pubspec.yaml @@ -16,3 +16,42 @@ dev_dependencies: build_runner: ^2.0.0 test: ^1.16.8 gql_tristate_value: ^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_tristate_value: + path: ../gql_tristate_value + 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 + end_to_end_test: + path: ../end_to_end_test diff --git a/codegen/gql_build/pubspec.yaml b/codegen/gql_build/pubspec.yaml index 475e7d17..4ab3770a 100644 --- a/codegen/gql_build/pubspec.yaml +++ b/codegen/gql_build/pubspec.yaml @@ -21,6 +21,45 @@ 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_tristate_value: + path: ../gql_tristate_value + 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_tristate: + path: ../end_to_end_test_tristate + end_to_end_test: + path: ../end_to_end_test topics: - graphql - gql diff --git a/codegen/gql_code_builder/lib/src/common.dart b/codegen/gql_code_builder/lib/src/common.dart index fbfb9a49..33ade380 100644 --- a/codegen/gql_code_builder/lib/src/common.dart +++ b/codegen/gql_code_builder/lib/src/common.dart @@ -88,9 +88,9 @@ const defaultTypeMap = { "Boolean": Reference("bool"), }; -Reference _typeRef(TypeNode type, Map typeMap) { +Reference _typeRef(TypeNode type, Map typeMap, Reference? fragmentRef) { if (type is NamedTypeNode) { - final ref = typeMap[type.name.value] ?? Reference(type.name.value); + final ref = fragmentRef ?? typeMap[type.name.value] ?? Reference(type.name.value); assert(ref.symbol != null, "Symbol for ${ref} must not be null"); return TypeReference( (b) => b @@ -104,7 +104,7 @@ Reference _typeRef(TypeNode type, Map typeMap) { ..url = "package:built_collection/built_collection.dart" ..symbol = "BuiltList" ..isNullable = !type.isNonNull - ..types.add(_typeRef(type.type, typeMap)), + ..types.add(_typeRef(type.type, typeMap, fragmentRef)), ); } throw Exception("Unrecognized TypeNode type"); @@ -162,10 +162,11 @@ Method buildGetter({ ...typeOverrides, }; - final returnType = fragmentRef ?? + final returnType = _typeRef( typeNode, typeMap, + fragmentRef ); return Method( diff --git a/codegen/gql_code_builder/lib/src/operation/data.dart b/codegen/gql_code_builder/lib/src/operation/data.dart index aef8bc40..86063f0a 100644 --- a/codegen/gql_code_builder/lib/src/operation/data.dart +++ b/codegen/gql_code_builder/lib/src/operation/data.dart @@ -163,6 +163,8 @@ List buildSelectionSetDataClasses({ ); } + final canonicalSelections = BuiltSet.of(selections.withoutFragmentSpreads); + final superclassSelectionNodes = superclassSelections.values .expand((selections) => selections.selections) .toSet(); @@ -230,7 +232,8 @@ List buildSelectionSetDataClasses({ fragmentRefMap: fragmentRefMap, ) else if (!built) - Class( + () { + final clazz = Class( (b) => b ..abstract = true ..name = builtClassName(name) @@ -250,7 +253,9 @@ List buildSelectionSetDataClasses({ isOverride: superclassSelections.isNotEmpty, ), ]), - ) + ); + return clazz; + }() else builtClass( name: name, diff --git a/codegen/gql_code_builder/pubspec.yaml b/codegen/gql_code_builder/pubspec.yaml index 6935aa83..afac8651 100644 --- a/codegen/gql_code_builder/pubspec.yaml +++ b/codegen/gql_code_builder/pubspec.yaml @@ -18,6 +18,45 @@ 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_tristate_value: + path: ../gql_tristate_value + 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_tristate: + path: ../end_to_end_test_tristate + end_to_end_test: + path: ../end_to_end_test topics: - graphql - gql diff --git a/codegen/gql_tristate_value/pubspec.yaml b/codegen/gql_tristate_value/pubspec.yaml index 00d9c97a..dd29657e 100644 --- a/codegen/gql_tristate_value/pubspec.yaml +++ b/codegen/gql_tristate_value/pubspec.yaml @@ -7,6 +7,45 @@ environment: dev_dependencies: test: ^1.16.8 lints: ^3.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: ../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 + end_to_end_test_tristate: + path: ../end_to_end_test_tristate + end_to_end_test: + path: ../end_to_end_test topics: - graphql - gql diff --git a/examples/gql_example_build/pubspec.yaml b/examples/gql_example_build/pubspec.yaml index b7f91883..d6c198f8 100644 --- a/examples/gql_example_build/pubspec.yaml +++ b/examples/gql_example_build/pubspec.yaml @@ -6,3 +6,42 @@ dev_dependencies: gql_build: ^0.9.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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + 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 e54763af..459dfd59 100644 --- a/examples/gql_example_cli/pubspec.yaml +++ b/examples/gql_example_cli/pubspec.yaml @@ -12,3 +12,42 @@ dev_dependencies: gql_build: ^0.9.0 gql_pedantic: ^1.0.2 dart_style: ^2.3.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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + 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 2a9ca013..c03c522f 100644 --- a/examples/gql_example_cli_github/pubspec.yaml +++ b/examples/gql_example_cli_github/pubspec.yaml @@ -13,3 +13,42 @@ dev_dependencies: dart_style: 2.3.3 gql_build: ^0.9.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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + 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 6eec4f48..4e06d9a3 100644 --- a/examples/gql_example_dio_link/pubspec.yaml +++ b/examples/gql_example_dio_link/pubspec.yaml @@ -8,3 +8,42 @@ dependencies: gql_link: ^1.0.0 gql_exec: ^1.0.0 gql_dio_link: ^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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + 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 20261044..bc644fc1 100644 --- a/examples/gql_example_flutter/pubspec.yaml +++ b/examples/gql_example_flutter/pubspec.yaml @@ -16,5 +16,46 @@ dev_dependencies: gql_build: ^0.9.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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + 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 ca2c0b0c..320d77ec 100644 --- a/examples/gql_example_http_auth_link/pubspec.yaml +++ b/examples/gql_example_http_auth_link/pubspec.yaml @@ -12,3 +12,42 @@ dependencies: dev_dependencies: gql_build: ^0.9.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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + end_to_end_test: + path: ../../codegen/end_to_end_test diff --git a/gql/pubspec.yaml b/gql/pubspec.yaml index e855c7a8..547c5ea5 100644 --- a/gql/pubspec.yaml +++ b/gql/pubspec.yaml @@ -12,6 +12,45 @@ 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_tristate_value: + path: ../codegen/gql_tristate_value + 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_tristate: + path: ../codegen/end_to_end_test_tristate + end_to_end_test: + path: ../codegen/end_to_end_test topics: - graphql - gql diff --git a/gql_pedantic/pubspec.yaml b/gql_pedantic/pubspec.yaml index 670afcf7..115f96cb 100644 --- a/gql_pedantic/pubspec.yaml +++ b/gql_pedantic/pubspec.yaml @@ -4,3 +4,42 @@ description: Even more opinionated lint rules. repository: https://github.com/gql-dart/gql environment: sdk: '>=2.12.0 <4.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_tristate_value: + path: ../codegen/gql_tristate_value + 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_tristate: + path: ../codegen/end_to_end_test_tristate + 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 e6e45d6d..f622da14 100644 --- a/links/gql_dedupe_link/pubspec.yaml +++ b/links/gql_dedupe_link/pubspec.yaml @@ -14,6 +14,45 @@ 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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + end_to_end_test: + path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_dio_link/pubspec.yaml b/links/gql_dio_link/pubspec.yaml index 8ccb578f..71c5b71d 100644 --- a/links/gql_dio_link/pubspec.yaml +++ b/links/gql_dio_link/pubspec.yaml @@ -18,6 +18,45 @@ 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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + end_to_end_test: + path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_error_link/pubspec.yaml b/links/gql_error_link/pubspec.yaml index 7cf3524c..70c5f7fd 100644 --- a/links/gql_error_link/pubspec.yaml +++ b/links/gql_error_link/pubspec.yaml @@ -14,6 +14,45 @@ 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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + end_to_end_test: + path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_exec/pubspec.yaml b/links/gql_exec/pubspec.yaml index 68d3e604..0a0a583e 100644 --- a/links/gql_exec/pubspec.yaml +++ b/links/gql_exec/pubspec.yaml @@ -11,6 +11,45 @@ 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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + end_to_end_test: + path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_http_link/pubspec.yaml b/links/gql_http_link/pubspec.yaml index 1ed60341..556f46f2 100644 --- a/links/gql_http_link/pubspec.yaml +++ b/links/gql_http_link/pubspec.yaml @@ -17,6 +17,45 @@ 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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + end_to_end_test: + path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_link/pubspec.yaml b/links/gql_link/pubspec.yaml index 5a951d87..ae5dc5de 100644 --- a/links/gql_link/pubspec.yaml +++ b/links/gql_link/pubspec.yaml @@ -12,6 +12,45 @@ 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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + end_to_end_test: + path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_transform_link/pubspec.yaml b/links/gql_transform_link/pubspec.yaml index 5175a77c..1ad8136a 100644 --- a/links/gql_transform_link/pubspec.yaml +++ b/links/gql_transform_link/pubspec.yaml @@ -12,6 +12,45 @@ 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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + end_to_end_test: + path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_websocket_link/pubspec.yaml b/links/gql_websocket_link/pubspec.yaml index f4ee609d..f80b069f 100644 --- a/links/gql_websocket_link/pubspec.yaml +++ b/links/gql_websocket_link/pubspec.yaml @@ -16,6 +16,45 @@ 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_tristate_value: + path: ../../codegen/gql_tristate_value + 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_tristate: + path: ../../codegen/end_to_end_test_tristate + end_to_end_test: + path: ../../codegen/end_to_end_test topics: - graphql - gql From 789047c093cf5129f695c6a6f2e333803e687392 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 7 Jan 2024 18:58:08 +0000 Subject: [PATCH 07/12] keep inline fragment spreads in selections --- ...interface_subtyped_fragments.data.gql.dart | 41 +-- ...terface_subtyped_fragments.data.gql.g.dart | 236 +---------------- ..._with_interface_subtyped_fragments.graphql | 48 ++-- .../__generated__/serializers.gql.dart | 2 - .../__generated__/serializers.gql.g.dart | 1 - codegen/gql_build/lib/src/data_builder.dart | 15 +- codegen/gql_code_builder/lib/data.dart | 35 ++- .../lib/src/inline_fragment_classes.dart | 237 ++++++++++++------ .../lib/src/operation/data.dart | 195 +++++++------- .../lib/src/when_extension.dart | 47 ++-- 10 files changed, 359 insertions(+), 498 deletions(-) diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.dart index 400d3487..67a7e587 100644 --- a/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.dart +++ b/codegen/end_to_end_test/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.dart @@ -28,7 +28,7 @@ abstract class GHeroWithInterfaceSubTypedFragmentsData @BuiltValueField(wireName: '__typename') String get G__typename; - GHeroWithInterfaceSubTypedFragmentsData_hero? get hero; + GheroFieldsFragmentData? get hero; static Serializer get serializer => _$gHeroWithInterfaceSubTypedFragmentsDataSerializer; @@ -45,45 +45,6 @@ abstract class GHeroWithInterfaceSubTypedFragmentsData ); } -abstract class GHeroWithInterfaceSubTypedFragmentsData_hero - implements - Built, - GheroFieldsFragment { - GHeroWithInterfaceSubTypedFragmentsData_hero._(); - - factory GHeroWithInterfaceSubTypedFragmentsData_hero( - [void 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; 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 20c08793..4f772a52 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 @@ -9,9 +9,6 @@ part of 'hero_with_interface_subtyped_fragments.data.gql.dart'; Serializer _$gHeroWithInterfaceSubTypedFragmentsDataSerializer = new _$GHeroWithInterfaceSubTypedFragmentsDataSerializer(); -Serializer - _$gHeroWithInterfaceSubTypedFragmentsDataHeroSerializer = - new _$GHeroWithInterfaceSubTypedFragmentsData_heroSerializer(); Serializer _$gheroFieldsFragmentDataBaseSerializer = new _$GheroFieldsFragmentData__baseSerializer(); @@ -69,8 +66,7 @@ class _$GHeroWithInterfaceSubTypedFragmentsDataSerializer result ..add('hero') ..add(serializers.serialize(value, - specifiedType: - const FullType(GHeroWithInterfaceSubTypedFragmentsData_hero))); + specifiedType: const FullType(GheroFieldsFragmentData))); } return result; } @@ -92,69 +88,9 @@ class _$GHeroWithInterfaceSubTypedFragmentsDataSerializer 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; + result.hero = serializers.deserialize(value, + specifiedType: const FullType(GheroFieldsFragmentData)) + as GheroFieldsFragmentData?; break; } } @@ -884,7 +820,7 @@ class _$GHeroWithInterfaceSubTypedFragmentsData @override final String G__typename; @override - final GHeroWithInterfaceSubTypedFragmentsData_hero? hero; + final GheroFieldsFragmentData? hero; factory _$GHeroWithInterfaceSubTypedFragmentsData( [void Function(GHeroWithInterfaceSubTypedFragmentsDataBuilder)? @@ -946,12 +882,9 @@ class GHeroWithInterfaceSubTypedFragmentsDataBuilder 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; + GheroFieldsFragmentData? _hero; + GheroFieldsFragmentData? get hero => _$this._hero; + set hero(GheroFieldsFragmentData? hero) => _$this._hero = hero; GHeroWithInterfaceSubTypedFragmentsDataBuilder() { GHeroWithInterfaceSubTypedFragmentsData._initializeBuilder(this); @@ -961,7 +894,7 @@ class GHeroWithInterfaceSubTypedFragmentsDataBuilder final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; - _hero = $v.hero?.toBuilder(); + _hero = $v.hero; _$v = null; } return this; @@ -983,156 +916,11 @@ class GHeroWithInterfaceSubTypedFragmentsDataBuilder 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._( + new _$GHeroWithInterfaceSubTypedFragmentsData._( 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')); + r'GHeroWithInterfaceSubTypedFragmentsData', 'G__typename'), + hero: hero); replace(_$result); return _$result; } diff --git a/codegen/end_to_end_test/lib/fragments/hero_with_interface_subtyped_fragments.graphql b/codegen/end_to_end_test/lib/fragments/hero_with_interface_subtyped_fragments.graphql index ef82071b..47f33c86 100644 --- a/codegen/end_to_end_test/lib/fragments/hero_with_interface_subtyped_fragments.graphql +++ b/codegen/end_to_end_test/lib/fragments/hero_with_interface_subtyped_fragments.graphql @@ -1,38 +1,38 @@ query HeroWithInterfaceSubTypedFragments($episode: Episode!) { - hero(episode: $episode) { - ...heroFieldsFragment - } + hero(episode: $episode) { + ...heroFieldsFragment + } } fragment heroFieldsFragment on Character { - id - name + id + name - ...on Human { - ...humanFieldsFragment - } + ...on Human { + ...humanFieldsFragment + } - ...on Droid { - ...droidFieldsFragment - } + ...on Droid { + ...droidFieldsFragment + } } fragment humanFieldsFragment on Human { - homePlanet - friends { - ...on Droid { - id - name - ...droidFieldsFragment - } - ...on Human { - id - name - homePlanet + homePlanet + friends { + ...on Droid { + id + name + ...droidFieldsFragment + } + ...on Human { + id + name + homePlanet + } } - } } fragment droidFieldsFragment on Droid { - primaryFunction + primaryFunction } 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 7782f836..424dbcd3 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 @@ -55,7 +55,6 @@ import 'package:end_to_end_test/fragments/__generated__/hero_with_interface_subt GheroFieldsFragmentData__asHuman_friends, GhumanFieldsFragmentData_friends, GHeroWithInterfaceSubTypedFragmentsData, - GHeroWithInterfaceSubTypedFragmentsData_hero, GdroidFieldsFragmentData, GheroFieldsFragmentData__asDroid, GheroFieldsFragmentData__asHuman, @@ -202,7 +201,6 @@ final SerializersBuilder _serializersBuilder = _$serializers.toBuilder() GHeroWithFragmentsVars, GHeroWithInterfaceSubTypedFragments, GHeroWithInterfaceSubTypedFragmentsData, - GHeroWithInterfaceSubTypedFragmentsData_hero, GHeroWithInterfaceSubTypedFragmentsVars, GHumanWithArgs, GHumanWithArgsData, 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 d4490de5..18d1f7eb 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 @@ -44,7 +44,6 @@ Serializers _$serializers = (new Serializers().toBuilder() ..add(GHeroWithFragmentsVars.serializer) ..add(GHeroWithInterfaceSubTypedFragments.serializer) ..add(GHeroWithInterfaceSubTypedFragmentsData.serializer) - ..add(GHeroWithInterfaceSubTypedFragmentsData_hero.serializer) ..add(GHeroWithInterfaceSubTypedFragmentsVars.serializer) ..add(GHumanWithArgs.serializer) ..add(GHumanWithArgsData.serializer) diff --git a/codegen/gql_build/lib/src/data_builder.dart b/codegen/gql_build/lib/src/data_builder.dart index 641c17a3..6c6ff083 100644 --- a/codegen/gql_build/lib/src/data_builder.dart +++ b/codegen/gql_build/lib/src/data_builder.dart @@ -35,17 +35,10 @@ class DataBuilder implements Builder { final doc = await readDocument(buildStep); final schema = await readDocument(buildStep, schemaId); - final generatedPartUrl = buildStep.inputId - .changeExtension(generatedFileExtension(dataExtension)) - .uri - .path; - - final library = buildDataLibrary( - addTypenames ? introspection.addTypenames(doc) : doc, - introspection.addTypenames(schema), - basename(generatedPartUrl), - typeOverrides, - whenExtensionConfig); + final generatedPartUrl = buildStep.inputId.changeExtension(generatedFileExtension(dataExtension)).uri.path; + + final library = buildDataLibrary(addTypenames ? introspection.addTypenames(doc) : doc, + introspection.addTypenames(schema), basename(generatedPartUrl), typeOverrides, whenExtensionConfig); return writeDocument( library, diff --git a/codegen/gql_code_builder/lib/data.dart b/codegen/gql_code_builder/lib/data.dart index 350db1f1..0b9c0174 100644 --- a/codegen/gql_code_builder/lib/data.dart +++ b/codegen/gql_code_builder/lib/data.dart @@ -1,6 +1,7 @@ import "package:built_collection/built_collection.dart"; import "package:code_builder/code_builder.dart"; import "package:gql/ast.dart"; +import "package:gql_code_builder/possible_types.dart"; import "package:gql_code_builder/src/config/when_extension_config.dart"; import "./source.dart"; @@ -8,18 +9,23 @@ import "./src/operation/data.dart"; export "package:gql_code_builder/src/config/when_extension_config.dart"; +typedef TypeName = String; + +typedef FragmentRefMap = Map<(TypeName, BuiltSet), Reference>; + Library buildDataLibrary( SourceNode docSource, SourceNode schemaSource, String partUrl, Map typeOverrides, [ - InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig = - const InlineFragmentSpreadWhenExtensionConfig( + InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig = const InlineFragmentSpreadWhenExtensionConfig( generateWhenExtensionMethod: false, generateMaybeWhenExtensionMethod: false, ), ]) { - final fragmentRefMap = , Reference>{}; + final fragmentRefMap = <(TypeName, BuiltSet), Reference>{}; + + final possibleTypesMap = _possibleTypesMap(schemaSource); final fragmentDataClasses = docSource.document.definitions .whereType() @@ -31,10 +37,13 @@ Library buildDataLibrary( typeOverrides, whenExtensionConfig, fragmentRefMap, + possibleTypesMap, ), ) .toList(); + print(fragmentRefMap); + final operationDataClasses = docSource.document.definitions .whereType() .expand( @@ -58,3 +67,23 @@ Library buildDataLibrary( ]), ); } + +Map> _possibleTypesMap(SourceNode source, + [Set? visitedSource, Map>? possibleTypesMap]) { + visitedSource ??= {}; + possibleTypesMap ??= {}; + + source.imports.forEach((s) { + if (!visitedSource!.contains(source.url)) { + visitedSource.add(source.url); + _possibleTypesMap(s, visitedSource, possibleTypesMap); + } + }); + + source.document.possibleTypesMap().forEach((key, value) { + possibleTypesMap![key] ??= {}; + possibleTypesMap[key]!.addAll(value); + }); + + return possibleTypesMap; +} diff --git a/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart b/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart index 27e1b11a..647817a3 100644 --- a/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart +++ b/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart @@ -1,6 +1,7 @@ import "package:built_collection/built_collection.dart"; import "package:code_builder/code_builder.dart"; import "package:gql/ast.dart"; +import "package:gql_code_builder/data.dart"; import "package:gql_code_builder/src/config/when_extension_config.dart"; import "package:gql_code_builder/src/when_extension.dart"; @@ -27,13 +28,92 @@ List buildInlineFragmentClasses({ required List inlineFragments, required bool built, required InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig, - required Map, Reference> fragmentRefMap, + required FragmentRefMap fragmentRefMap, }) { final whenExtension = inlineFragmentWhenExtension( baseTypeName: name, inlineFragments: inlineFragments, config: whenExtensionConfig, ); + + List selectionsForInlineFragment(InlineFragmentNode inlineFragment) { + final fragSelections = mergeSelections( + [ + ...selections.whereType(), + ...selections.whereType(), + ...inlineFragment.selectionSet.selections, + ], + fragmentMap, + ); + + return fragSelections; + } + + Reference? existingFragmentWithSameSelections(String typeName, List fragmentSelections) { + final existing = fragmentRefMap[( + typeName, + BuiltSet.of( + fragmentSelections.withoutFragmentSpreads, + ) + )]; + print("existing: $existing on $typeName with selections: $fragmentSelections"); + return existing; + } + + List buildSelectionSetClassesForInlineFragment( + InlineFragmentNode inlineFragment, List fragmentSelections) => + buildSelectionSetDataClasses( + name: _inlineFragmentName(name, inlineFragment), + selections: fragmentSelections, + fragmentMap: fragmentMap, + schemaSource: schemaSource, + type: inlineFragment.typeCondition!.on.name.value, + typeOverrides: typeOverrides, + superclassSelections: { + name: SourceSelections(url: null, selections: selections), + }, + built: built, + fragmentRefMap: fragmentRefMap, + whenExtensionConfig: whenExtensionConfig, + ); + + List baseClass() { + final baseSelections = mergeSelections([ + ...selections.whereType(), + ...selections.whereType(), + ], fragmentMap, true); + + final existingFragment = existingFragmentWithSameSelections(type, baseSelections); + + if (existingFragment != null) { + final existingFragmentName = existingFragment.symbol; + final targetName = _inlineFragmentBaseName(name); + + print( + "Found existing fragment $existingFragmentName with same selections as $targetName. Using $existingFragmentName instead."); + print("adding typedef"); + + return []; + } else { + print("&&&&&&& no existing fragment found for $name on $type with selections: $baseSelections"); + } + + return [ + ...buildSelectionSetDataClasses( + name: _inlineFragmentBaseName(name), + selections: baseSelections, + fragmentMap: fragmentMap, + schemaSource: schemaSource, + type: type, + typeOverrides: typeOverrides, + superclassSelections: {name: SourceSelections(url: null, selections: selections)}, + built: built, + whenExtensionConfig: whenExtensionConfig, + fragmentRefMap: fragmentRefMap, + ), + ]; + } + return [ Class( (b) => b @@ -53,85 +133,102 @@ List buildInlineFragmentClasses({ ..._inlineFragmentRootSerializationMethods( name: builtClassName(name), inlineFragments: inlineFragments, + fragmentRefMap: fragmentRefMap, ), ]), ), if (whenExtension != null) whenExtension, - ...buildSelectionSetDataClasses( - name: "${name}__base", - selections: mergeSelections( - [ - ...selections.whereType(), - ...selections.whereType(), - ], - fragmentMap, - ), - fragmentMap: fragmentMap, - schemaSource: schemaSource, - type: type, - typeOverrides: typeOverrides, - superclassSelections: { - name: SourceSelections(url: null, selections: selections) - }, - built: built, - whenExtensionConfig: whenExtensionConfig, - fragmentRefMap: fragmentRefMap, - ), + /// the base class for all specialized inline fragments that has the common fields + ...baseClass(), + + /// specialized inline fragments, which include the common fields and the fragment fields for that fragment /// TODO: Handle inline fragments without a type condition /// https://spec.graphql.org/June2018/#sec-Inline-Fragments - ...inlineFragments.where((frag) => frag.typeCondition != null).expand( - (inlineFragment) => buildSelectionSetDataClasses( - name: "${name}__as${inlineFragment.typeCondition!.on.name.value}", - selections: mergeSelections( - [ - ...selections.whereType(), - ...selections.whereType(), - ...inlineFragment.selectionSet.selections, - ], - fragmentMap, - ), - fragmentMap: fragmentMap, - schemaSource: schemaSource, - type: inlineFragment.typeCondition!.on.name.value, - typeOverrides: typeOverrides, - superclassSelections: { - name: SourceSelections(url: null, selections: selections) - }, - built: built, - fragmentRefMap: fragmentRefMap, - whenExtensionConfig: whenExtensionConfig), - ), + ...inlineFragments + .where((frag) => frag.typeCondition != null) + .map( + (frag) => ( + inlineFragment: frag, + selections: selectionsForInlineFragment(frag), + ), + ) + .expand( + (fragmentWithSelections) { + final (:inlineFragment, selections: fragmentSelections) = fragmentWithSelections; + + final typeName = inlineFragment.typeCondition!.on.name.value; + + final existingFragment = existingFragmentWithSameSelections(typeName, fragmentSelections); + + if (existingFragment != null) { + final existingFragmentName = existingFragment.symbol; + final targetName = _inlineFragmentName(name, inlineFragment); + + print( + "Found existing fragment $existingFragmentName with same selections as $targetName. Using $existingFragmentName instead."); + print("adding typedef"); + + return []; + } + + return buildSelectionSetClassesForInlineFragment( + inlineFragment, + fragmentSelections, + ); + }, + ), ]; } +String _inlineFragmentName(String baseName, InlineFragmentNode inlineFragment) => + "${baseName}__as${inlineFragment.typeCondition!.on.name.value}"; + +String _inlineFragmentBaseName(String baseName) => "${baseName}__base"; + List _inlineFragmentRootSerializationMethods({ required String name, required List inlineFragments, -}) => - [ - buildSerializerGetter(name).rebuild( - (b) => b - ..body = TypeReference((b) => b - ..symbol = "InlineFragmentSerializer" - ..url = - "package:gql_code_builder/src/serializers/inline_fragment_serializer.dart" - ..types.add(refer(name))).call([ - literalString(name), - refer("${name}__base"), - literalMap( - /// TODO: Handle inline fragments without a type condition - /// https://spec.graphql.org/June2018/#sec-Inline-Fragments - { - for (final v in inlineFragments - .where((frag) => frag.typeCondition != null)) - "${v.typeCondition!.on.name.value}": refer( - "${name}__as${v.typeCondition!.on.name.value}", - ) - }, - ), - ]).code, - ), - buildToJsonGetter(name), - buildFromJsonGetter(name), - ]; + required FragmentRefMap fragmentRefMap, +}) { + final toJson = buildToJsonGetter(name); + final fromJson = buildFromJsonGetter(name); + + final inlineSerializer = _inlineFragmentSerializer(name, inlineFragments, fragmentRefMap); + + return [ + inlineSerializer, + toJson, + fromJson, + ]; +} + +Method _inlineFragmentSerializer( + String name, + List inlineFragments, + FragmentRefMap fragmentRefMap, +) { + final baseSerializer = buildSerializerGetter(name); + + final inlineSerializer = baseSerializer.rebuild( + (b) => b + ..body = TypeReference((b) => b + ..symbol = "InlineFragmentSerializer" + ..url = "package:gql_code_builder/src/serializers/inline_fragment_serializer.dart" + ..types.add(refer(name))).call([ + literalString(name), + refer(_inlineFragmentBaseName(name)), + literalMap( + /// TODO: Handle inline fragments without a type condition + /// https://spec.graphql.org/June2018/#sec-Inline-Fragments + { + for (final v in inlineFragments.where((frag) => frag.typeCondition != null)) + "${v.typeCondition!.on.name.value}": refer( + _inlineFragmentName(name, v), + ) + }, + ), + ]).code, + ); + return inlineSerializer; +} diff --git a/codegen/gql_code_builder/lib/src/operation/data.dart b/codegen/gql_code_builder/lib/src/operation/data.dart index 86063f0a..dd6a5d51 100644 --- a/codegen/gql_code_builder/lib/src/operation/data.dart +++ b/codegen/gql_code_builder/lib/src/operation/data.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/data.dart"; import "package:gql_code_builder/src/config/when_extension_config.dart"; import "../../source.dart"; @@ -15,7 +16,7 @@ List buildOperationDataClasses( SourceNode schemaSource, Map typeOverrides, InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig, - Map, Reference> fragmentRefMap, + FragmentRefMap fragmentRefMap, ) { if (op.name == null) { throw Exception("Operations must be named"); @@ -24,10 +25,7 @@ List buildOperationDataClasses( final fragmentMap = _fragmentMap(docSource); return buildSelectionSetDataClasses( name: "${op.name!.value}Data", - selections: mergeSelections( - op.selectionSet.selections, - fragmentMap, - ), + selections: mergeSelections(op.selectionSet.selections, fragmentMap, true), schemaSource: schemaSource, type: _operationType( schemaSource.document, @@ -47,25 +45,37 @@ List buildFragmentDataClasses( SourceNode schemaSource, Map typeOverrides, InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig, - Map, Reference> fragmentRefMap, + FragmentRefMap fragmentRefMap, + Map> possibleTypesMap, ) { final fragmentMap = _fragmentMap(docSource); - final selections = mergeSelections( - frag.selectionSet.selections, - fragmentMap, - ); + final selections = mergeSelections(frag.selectionSet.selections, fragmentMap, true); final set = BuiltSet.of(selections.withoutFragmentSpreads); - if (fragmentRefMap.containsKey(set)) { + final fragmentType = frag.typeCondition.on.name.value; + + if (fragmentRefMap.containsKey((fragmentType, set))) { print( - "***** warning: duplicated fragment found: ${frag.name.value} in ${docSource.url}, previous defintion with same data ${fragmentRefMap[set]}"); + "***** warning: duplicated fragment found: ${frag.name.value} on ${frag.typeCondition.on.name.value} in ${docSource.url}, previous defintion with same data ${fragmentRefMap[( + fragmentType, + set + )]}"); + + print("on type: $fragmentType"); } - fragmentRefMap[set] = refer( + fragmentRefMap[(fragmentType, set)] = refer( builtClassName("${frag.name.value}Data"), (docSource.url ?? "") + "#data", ); + //TODO + /*for (final possibleType in possibleTypesMap[fragmentType] ?? {}) { + fragmentRefMap[(possibleType, set)] = refer( + builtClassName("${frag.name.value}Data"), + (docSource.url ?? "") + "#data", + ); + }*/ return [ // abstract class that will implemented by any class that uses the fragment @@ -119,8 +129,7 @@ String _operationType( } Map _fragmentMap(SourceNode source) => { - for (final def - in source.document.definitions.whereType()) + for (final def in source.document.definitions.whereType()) def.name.value: SourceSelections( url: source.url, selections: def.selectionSet.selections, @@ -147,12 +156,11 @@ List buildSelectionSetDataClasses({ required Map superclassSelections, bool built = true, required InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig, - required Map, Reference> fragmentRefMap, + required FragmentRefMap fragmentRefMap, }) { for (final selection in selections.whereType()) { if (!fragmentMap.containsKey(selection.name.value)) { - throw Exception( - "Couldn't find fragment definition for fragment spread '${selection.name.value}'"); + throw Exception("Couldn't find fragment definition for fragment spread '${selection.name.value}'"); } superclassSelections["${selection.name.value}"] = SourceSelections( url: fragmentMap[selection.name.value]!.url, @@ -165,9 +173,7 @@ List buildSelectionSetDataClasses({ final canonicalSelections = BuiltSet.of(selections.withoutFragmentSpreads); - final superclassSelectionNodes = superclassSelections.values - .expand((selections) => selections.selections) - .toSet(); + final superclassSelectionNodes = superclassSelections.values.expand((selections) => selections.selections).toSet(); final fieldsThatAreSingleFragmentSpreads = {}; @@ -188,13 +194,33 @@ List buildSelectionSetDataClasses({ Reference? fragmentRef; if (getterSelections != null) { - final withoutFragmentSpreads = - getterSelections.selections.withoutFragmentSpreads.toBuiltSet(); + final mergedGetterSelections = [ + ...mergeSelections(getterSelections.selections, fragmentMap, true), + ]; + + if (node.name.value == "hero") { + print("mergedGetterSelections: $mergedGetterSelections from ${getterSelections.selections}"); + } + + final withoutFragmentSpreads = mergedGetterSelections.withoutFragmentSpreads.toBuiltSet(); + + final fieldTypeDefNode = getTypeDefinitionNode( + schemaSource.document, + unwrapTypeNode(typeNode).name.value, + ); - final hasMatchingFragment = fragmentRefMap[withoutFragmentSpreads]; + if (fieldTypeDefNode == null) { + throw Exception("Couldn't find type definition for ${unwrapTypeNode(typeNode).name.value}"); + } + + final hasMatchingFragment = fragmentRefMap[(fieldTypeDefNode.name.value, withoutFragmentSpreads)]; if (hasMatchingFragment != null) { fieldsThatAreSingleFragmentSpreads.add(node); + } else if (node.name.value == "hero") { + print( + "no matching fragment for ${node.name.value} on ${fieldTypeDefNode.name.value} with selections: $withoutFragmentSpreads, original selections: ${node.selectionSet?.selections}"); + print(fragmentRefMap); } fragmentRef = hasMatchingFragment; @@ -233,36 +259,35 @@ List buildSelectionSetDataClasses({ ) else if (!built) () { - final clazz = Class( - (b) => b - ..abstract = true - ..name = builtClassName(name) - ..implements.addAll( - superclassSelections.keys.map( - (superName) => refer( - builtClassName(superName), - (superclassSelections[superName]?.url ?? "") + "#data", + final clazz = Class( + (b) => b + ..abstract = true + ..name = builtClassName(name) + ..implements.addAll( + superclassSelections.keys.map( + (superName) => refer( + builtClassName(superName), + (superclassSelections[superName]?.url ?? "") + "#data", + ), ), - ), - ) - ..methods.addAll([ - ...fieldGetters, - buildToJsonGetter( - builtClassName(name), - implemented: false, - isOverride: superclassSelections.isNotEmpty, - ), - ]), - ); - return clazz; - }() + ) + ..methods.addAll([ + ...fieldGetters, + buildToJsonGetter( + builtClassName(name), + implemented: false, + isOverride: superclassSelections.isNotEmpty, + ), + ]), + ); + return clazz; + }() else builtClass( name: name, getters: fieldGetters, initializers: { - if (fieldGetters.any((getter) => getter.name == "G__typename")) - "G__typename": literalString(type), + if (fieldGetters.any((getter) => getter.name == "G__typename")) "G__typename": literalString(type), }, superclassSelections: superclassSelections, ), @@ -270,9 +295,7 @@ List buildSelectionSetDataClasses({ ...selections .whereType() .where( - (field) => - field.selectionSet != null && - !fieldsThatAreSingleFragmentSpreads.contains(field), + (field) => field.selectionSet != null && !fieldsThatAreSingleFragmentSpreads.contains(field), ) .expand( (field) => buildSelectionSetDataClasses( @@ -303,11 +326,9 @@ List buildSelectionSetDataClasses({ } /// Deeply merges field nodes -List mergeSelections( - List selections, - Map fragmentMap, -) => - _expandFragmentSpreads(selections, fragmentMap) +List mergeSelections(List selections, Map fragmentMap, + [bool keepInlineFragments = true]) => + _expandFragmentSpreads(selections, fragmentMap, keepInlineFragments) .fold>( {}, (selectionMap, selection) { @@ -317,23 +338,25 @@ List mergeSelections( selectionMap[key] = selection; } else { final existingNode = selectionMap[key]; - final existingSelections = existingNode is FieldNode && - existingNode.selectionSet != null + final existingSelections = existingNode is FieldNode && existingNode.selectionSet != null ? existingNode.selectionSet!.selections : []; selectionMap[key] = FieldNode( - name: selection.name, - alias: selection.alias, - selectionSet: SelectionSetNode( - selections: mergeSelections( - [ - ...existingSelections, - ...selection.selectionSet!.selections - ], + name: selection.name, + alias: selection.alias, + selectionSet: SelectionSetNode( + selections: mergeSelections( + [...existingSelections, ...selection.selectionSet!.selections], fragmentMap, - ))); + keepInlineFragments, + ), + ), + ); } } else { + if (selectionMap[selection.hashCode.toString()] != null) { + print("duplicate selection or hash coll: $selection"); + } selectionMap[selection.hashCode.toString()] = selection; } return selectionMap; @@ -346,6 +369,7 @@ List _expandFragmentSpreads( List selections, Map fragmentMap, [ bool retainFragmentSpreads = true, + bool keepInlineFragments = true, ]) => selections.expand( (selection) { @@ -356,8 +380,7 @@ List _expandFragmentSpreads( ); } - final fragmentSelections = - fragmentMap[selection.name.value]!.selections; + final fragmentSelections = fragmentMap[selection.name.value]!.selections; return [ if (retainFragmentSpreads) selection, @@ -365,10 +388,11 @@ List _expandFragmentSpreads( [ ...fragmentSelections.whereType(), ...fragmentSelections.whereType(), + if (keepInlineFragments) ...fragmentSelections.whereType(), ], fragmentMap, - false, - ) + keepInlineFragments, + ), ]; } return [selection]; @@ -395,9 +419,7 @@ Map _fragmentSelectionsForField( "${entry.key}_${field.alias?.value ?? field.name.value}", SourceSelections( url: entry.value.url, - selections: selection.selectionSet!.selections - .whereType() - .toList(), + selections: selection.selectionSet!.selections.whereType().toList(), ), ), ), @@ -421,8 +443,7 @@ TypeNode _getFieldTypeNode( } else if (node is InterfaceTypeDefinitionNode) { fields = node.fields; } else { - throw Exception( - "${node.name.value} is not an ObjectTypeDefinitionNode or InterfaceTypeDefinitionNode"); + throw Exception("${node.name.value} is not an ObjectTypeDefinitionNode or InterfaceTypeDefinitionNode"); } return fields .firstWhere( @@ -432,25 +453,15 @@ TypeNode _getFieldTypeNode( } extension IsSingleFragmentSpread on SelectionSetNode { - Iterable get withoutTypeName => selections.where((selection) => - selection is! FieldNode || selection.name.value != "__typename"); - - bool get isSingleFragmentSpread => - withoutTypeName.length == 1 && - withoutTypeName.first is FragmentSpreadNode; - - Iterable get fragmentSpreads => - selections.whereType(); + Iterable get fragmentSpreads => selections.whereType(); - Iterable get inlineFragments => - selections.whereType(); + Iterable get inlineFragments => selections.whereType(); Iterable get fields => selections.whereType(); } extension WithoutFragmentSpreads on Iterable { - Iterable get withoutFragmentSpreads => - where((selection) => selection is! FragmentSpreadNode).map((e) { + Iterable get withoutFragmentSpreads => where((selection) => selection is! FragmentSpreadNode).map((e) { if (e is FieldNode) { if (e.selectionSet == null) return e; return FieldNode( @@ -459,8 +470,7 @@ extension WithoutFragmentSpreads on Iterable { arguments: e.arguments, directives: e.directives, selectionSet: SelectionSetNode( - selections: - e.selectionSet!.selections.withoutFragmentSpreads.toList(), + selections: e.selectionSet!.selections.withoutFragmentSpreads.toList(), ), ); } @@ -469,8 +479,7 @@ extension WithoutFragmentSpreads on Iterable { typeCondition: e.typeCondition, directives: e.directives, selectionSet: SelectionSetNode( - selections: - e.selectionSet.selections.withoutFragmentSpreads.toList(), + selections: e.selectionSet.selections.withoutFragmentSpreads.toList(), ), ); } diff --git a/codegen/gql_code_builder/lib/src/when_extension.dart b/codegen/gql_code_builder/lib/src/when_extension.dart index 52987e54..0813c667 100644 --- a/codegen/gql_code_builder/lib/src/when_extension.dart +++ b/codegen/gql_code_builder/lib/src/when_extension.dart @@ -7,11 +7,9 @@ import "package:gql_code_builder/src/utils/uncapitalize.dart"; // static building blocks for the generated code final _genericTypeParam = TypeReference((b) => b..symbol = "_T"); -final _orElseFunctionType = - FunctionType((b) => b..returnType = _genericTypeParam); +final _orElseFunctionType = FunctionType((b) => b..returnType = _genericTypeParam); -String _getSchemaTypeName(InlineFragmentNode node) => - node.typeCondition!.on.name.value; +String _getSchemaTypeName(InlineFragmentNode node) => node.typeCondition!.on.name.value; final _orElseFunctionRef = refer("orElse"); final _orElseInvocation = _orElseFunctionRef.call([]); @@ -28,8 +26,7 @@ final _curlyBracketOpen = Code("{"); final _curlyBracketClose = Code("}"); -Code _caseStatement(InlineFragmentNode inlineFragment) => - Code("case '${_getSchemaTypeName(inlineFragment)}': "); +Code _caseStatement(InlineFragmentNode inlineFragment) => Code("case '${_getSchemaTypeName(inlineFragment)}': "); /// returns an Extension that implements the `when` method and/or the `maybeWhen` method /// that makes it more convenient to use the union types or interfaces without resorting to @@ -40,13 +37,11 @@ Extension? inlineFragmentWhenExtension( {required String baseTypeName, required List inlineFragments, required InlineFragmentSpreadWhenExtensionConfig config}) { - final inlineFragmentsWithTypConditions = inlineFragments - .where((inlineFragment) => inlineFragment.typeCondition != null) - .toList(); + final inlineFragmentsWithTypConditions = + inlineFragments.where((inlineFragment) => inlineFragment.typeCondition != null).toList(); final nothingToDo = inlineFragmentsWithTypConditions.isEmpty || - (!config.generateWhenExtensionMethod && - !config.generateMaybeWhenExtensionMethod); + (!config.generateWhenExtensionMethod && !config.generateMaybeWhenExtensionMethod); if (nothingToDo) { return null; @@ -59,10 +54,7 @@ Extension? inlineFragmentWhenExtension( /// a pool of parameter names which have already been used /// so we can avoid name clashes - final Set usedParameterNames = { - _orElseFunctionRef.symbol!, - _genericTypeParam.symbol - }; + final Set usedParameterNames = {_orElseFunctionRef.symbol!, _genericTypeParam.symbol}; final Map parameterNamesPerInlineNode = {}; @@ -72,8 +64,7 @@ Extension? inlineFragmentWhenExtension( /// example: if the typeCondition is "Human", the parameter name will be "human" /// if the typeCondition is "Human" and "human" is already taken, the parameter name will be "ghuman" /// if the typeCondition is "orElse", the parameter name will be "gorElse" because "orElse" is reserved - String getParameterName(InlineFragmentNode node) => - parameterNamesPerInlineNode.putIfAbsent(node, () { + String getParameterName(InlineFragmentNode node) => parameterNamesPerInlineNode.putIfAbsent(node, () { var name = identifier(uncapitalize(_getSchemaTypeName(node))); while (usedParameterNames.contains(name)) { @@ -123,8 +114,7 @@ Extension? inlineFragmentWhenExtension( ..name = getParameterName(inlineFragment) ..type = FunctionType((b) => b ..returnType = _genericTypeParam - ..requiredParameters - .add(Reference(getGeneratedTypeName(inlineFragment)))) + ..requiredParameters.add(Reference(getGeneratedTypeName(inlineFragment)))) ..named = true ..required = true), ), @@ -141,11 +131,10 @@ Extension? inlineFragmentWhenExtension( ..body = Block.of([ _switchTypeName, _curlyBracketOpen, - ...inlineFragmentsWithTypConditions - .map((inlineFragment) => Block.of([ - _caseStatement(inlineFragment), - whenCaseBody(inlineFragment), - ])), + ...inlineFragmentsWithTypConditions.map((inlineFragment) => Block.of([ + _caseStatement(inlineFragment), + whenCaseBody(inlineFragment), + ])), _defaultCallOrElse, _curlyBracketClose, ])), @@ -183,12 +172,10 @@ Extension? inlineFragmentWhenExtension( [ _switchTypeName, _curlyBracketOpen, - ...inlineFragments - .where((element) => element.typeCondition != null) - .map((inlineFragment) => Block.of([ - _caseStatement(inlineFragment), - maybeWhenCaseBody(inlineFragment), - ])), + ...inlineFragments.where((element) => element.typeCondition != null).map((inlineFragment) => Block.of([ + _caseStatement(inlineFragment), + maybeWhenCaseBody(inlineFragment), + ])), _defaultCallOrElse, _curlyBracketClose, ], From 35105f420c3531d366373f477c4af743916b17d1 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 7 Jan 2024 19:13:53 +0000 Subject: [PATCH 08/12] mutlipack --- codegen/end_to_end_test/pubspec.yaml | 39 --------------- .../fragments_inline_nesting_test.dart | 49 +++++++++++++------ codegen/end_to_end_test_tristate/pubspec.yaml | 39 --------------- codegen/gql_build/pubspec.yaml | 39 --------------- codegen/gql_code_builder/pubspec.yaml | 39 --------------- codegen/gql_tristate_value/pubspec.yaml | 39 --------------- examples/gql_example_build/pubspec.yaml | 39 --------------- examples/gql_example_cli/pubspec.yaml | 39 --------------- examples/gql_example_cli_github/pubspec.yaml | 39 --------------- examples/gql_example_dio_link/pubspec.yaml | 39 --------------- examples/gql_example_flutter/pubspec.yaml | 41 ---------------- .../gql_example_http_auth_link/pubspec.yaml | 39 --------------- gql/lib/src/ast/ast.dart | 3 ++ gql/pubspec.yaml | 39 --------------- gql_pedantic/pubspec.yaml | 39 --------------- links/gql_dedupe_link/pubspec.yaml | 39 --------------- links/gql_dio_link/pubspec.yaml | 39 --------------- links/gql_error_link/pubspec.yaml | 39 --------------- links/gql_exec/pubspec.yaml | 39 --------------- links/gql_http_link/pubspec.yaml | 39 --------------- links/gql_link/pubspec.yaml | 39 --------------- links/gql_transform_link/pubspec.yaml | 39 --------------- links/gql_websocket_link/pubspec.yaml | 39 --------------- 23 files changed, 36 insertions(+), 837 deletions(-) diff --git a/codegen/end_to_end_test/pubspec.yaml b/codegen/end_to_end_test/pubspec.yaml index 886e4976..a44d3a61 100644 --- a/codegen/end_to_end_test/pubspec.yaml +++ b/codegen/end_to_end_test/pubspec.yaml @@ -15,42 +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_tristate_value: - path: ../gql_tristate_value - 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 - end_to_end_test_tristate: - path: ../end_to_end_test_tristate diff --git a/codegen/end_to_end_test/test/operation/fragments_inline_nesting_test.dart b/codegen/end_to_end_test/test/operation/fragments_inline_nesting_test.dart index 17f3336e..159276b0 100644 --- a/codegen/end_to_end_test/test/operation/fragments_inline_nesting_test.dart +++ b/codegen/end_to_end_test/test/operation/fragments_inline_nesting_test.dart @@ -11,12 +11,7 @@ void main() { "name": "Luke", "homePlanet": "Tattoine", "friends": [ - { - "__typename": "Droid", - "id": "r2d2", - "name": "R2-D2", - "primaryFunction": "Astromech" - }, + {"__typename": "Droid", "id": "r2d2", "name": "R2-D2", "primaryFunction": "Astromech"}, { "__typename": "Human", "id": "han", @@ -32,16 +27,14 @@ void main() { expect(gqlHuman?.name, equals("Luke")); expect(gqlHuman?.homePlanet, equals("Tattoine")); - final gqlHuman_droidFriends = gqlHuman?.friends - ?.whereType(); + 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(); + final gqlHuman_humanFriends = gqlHuman?.friends?.whereType(); expect(gqlHuman_humanFriends?.first.id, equals("han")); expect(gqlHuman_humanFriends?.first.name, equals("Han Solo")); @@ -77,12 +70,7 @@ void main() { "name": "Obiwan", "homePlanet": "Stewjon", "friends": [ - { - "__typename": "Droid", - "id": "r2d2", - "name": "R2-D2", - "primaryFunction": "Astromech" - }, + {"__typename": "Droid", "id": "r2d2", "name": "R2-D2", "primaryFunction": "Astromech"}, { "__typename": "Human", "id": "luke", @@ -94,5 +82,34 @@ void main() { expect(obiwan.toJson(), equals(json)); }); + + test("complete data response class test", () { + var json = { + "__typename": "Query", + "hero": { + "__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 response = GHeroWithInterfaceSubTypedFragmentsData.fromJson(json); + + expect(response?.toJson(), json); + }); }); } diff --git a/codegen/end_to_end_test_tristate/pubspec.yaml b/codegen/end_to_end_test_tristate/pubspec.yaml index fb70ee02..9da7f779 100644 --- a/codegen/end_to_end_test_tristate/pubspec.yaml +++ b/codegen/end_to_end_test_tristate/pubspec.yaml @@ -16,42 +16,3 @@ dev_dependencies: build_runner: ^2.0.0 test: ^1.16.8 gql_tristate_value: ^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_tristate_value: - path: ../gql_tristate_value - 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 - end_to_end_test: - path: ../end_to_end_test diff --git a/codegen/gql_build/pubspec.yaml b/codegen/gql_build/pubspec.yaml index 4ab3770a..475e7d17 100644 --- a/codegen/gql_build/pubspec.yaml +++ b/codegen/gql_build/pubspec.yaml @@ -21,45 +21,6 @@ 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_tristate_value: - path: ../gql_tristate_value - 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_tristate: - path: ../end_to_end_test_tristate - end_to_end_test: - path: ../end_to_end_test topics: - graphql - gql diff --git a/codegen/gql_code_builder/pubspec.yaml b/codegen/gql_code_builder/pubspec.yaml index afac8651..6935aa83 100644 --- a/codegen/gql_code_builder/pubspec.yaml +++ b/codegen/gql_code_builder/pubspec.yaml @@ -18,45 +18,6 @@ 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_tristate_value: - path: ../gql_tristate_value - 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_tristate: - path: ../end_to_end_test_tristate - end_to_end_test: - path: ../end_to_end_test topics: - graphql - gql diff --git a/codegen/gql_tristate_value/pubspec.yaml b/codegen/gql_tristate_value/pubspec.yaml index dd29657e..00d9c97a 100644 --- a/codegen/gql_tristate_value/pubspec.yaml +++ b/codegen/gql_tristate_value/pubspec.yaml @@ -7,45 +7,6 @@ environment: dev_dependencies: test: ^1.16.8 lints: ^3.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: ../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 - end_to_end_test_tristate: - path: ../end_to_end_test_tristate - end_to_end_test: - path: ../end_to_end_test topics: - graphql - gql diff --git a/examples/gql_example_build/pubspec.yaml b/examples/gql_example_build/pubspec.yaml index d6c198f8..b7f91883 100644 --- a/examples/gql_example_build/pubspec.yaml +++ b/examples/gql_example_build/pubspec.yaml @@ -6,42 +6,3 @@ dev_dependencies: gql_build: ^0.9.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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - 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 459dfd59..e54763af 100644 --- a/examples/gql_example_cli/pubspec.yaml +++ b/examples/gql_example_cli/pubspec.yaml @@ -12,42 +12,3 @@ dev_dependencies: gql_build: ^0.9.0 gql_pedantic: ^1.0.2 dart_style: ^2.3.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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - 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 c03c522f..2a9ca013 100644 --- a/examples/gql_example_cli_github/pubspec.yaml +++ b/examples/gql_example_cli_github/pubspec.yaml @@ -13,42 +13,3 @@ dev_dependencies: dart_style: 2.3.3 gql_build: ^0.9.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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - 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 4e06d9a3..6eec4f48 100644 --- a/examples/gql_example_dio_link/pubspec.yaml +++ b/examples/gql_example_dio_link/pubspec.yaml @@ -8,42 +8,3 @@ dependencies: gql_link: ^1.0.0 gql_exec: ^1.0.0 gql_dio_link: ^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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - 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 bc644fc1..20261044 100644 --- a/examples/gql_example_flutter/pubspec.yaml +++ b/examples/gql_example_flutter/pubspec.yaml @@ -16,46 +16,5 @@ dev_dependencies: gql_build: ^0.9.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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - 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 320d77ec..ca2c0b0c 100644 --- a/examples/gql_example_http_auth_link/pubspec.yaml +++ b/examples/gql_example_http_auth_link/pubspec.yaml @@ -12,42 +12,3 @@ dependencies: dev_dependencies: gql_build: ^0.9.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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - end_to_end_test: - path: ../../codegen/end_to_end_test diff --git a/gql/lib/src/ast/ast.dart b/gql/lib/src/ast/ast.dart index 1662fae0..72715a53 100644 --- a/gql/lib/src/ast/ast.dart +++ b/gql/lib/src/ast/ast.dart @@ -202,6 +202,9 @@ class FieldNode extends SelectionNode { arguments, directives, ]; + + @override + String toString() => "FieldNode(${(alias ?? name).value})"; } class ArgumentNode extends Node { diff --git a/gql/pubspec.yaml b/gql/pubspec.yaml index 547c5ea5..e855c7a8 100644 --- a/gql/pubspec.yaml +++ b/gql/pubspec.yaml @@ -12,45 +12,6 @@ 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_tristate_value: - path: ../codegen/gql_tristate_value - 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_tristate: - path: ../codegen/end_to_end_test_tristate - end_to_end_test: - path: ../codegen/end_to_end_test topics: - graphql - gql diff --git a/gql_pedantic/pubspec.yaml b/gql_pedantic/pubspec.yaml index 115f96cb..670afcf7 100644 --- a/gql_pedantic/pubspec.yaml +++ b/gql_pedantic/pubspec.yaml @@ -4,42 +4,3 @@ description: Even more opinionated lint rules. repository: https://github.com/gql-dart/gql environment: sdk: '>=2.12.0 <4.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_tristate_value: - path: ../codegen/gql_tristate_value - 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_tristate: - path: ../codegen/end_to_end_test_tristate - 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 f622da14..e6e45d6d 100644 --- a/links/gql_dedupe_link/pubspec.yaml +++ b/links/gql_dedupe_link/pubspec.yaml @@ -14,45 +14,6 @@ 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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - end_to_end_test: - path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_dio_link/pubspec.yaml b/links/gql_dio_link/pubspec.yaml index 71c5b71d..8ccb578f 100644 --- a/links/gql_dio_link/pubspec.yaml +++ b/links/gql_dio_link/pubspec.yaml @@ -18,45 +18,6 @@ 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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - end_to_end_test: - path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_error_link/pubspec.yaml b/links/gql_error_link/pubspec.yaml index 70c5f7fd..7cf3524c 100644 --- a/links/gql_error_link/pubspec.yaml +++ b/links/gql_error_link/pubspec.yaml @@ -14,45 +14,6 @@ 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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - end_to_end_test: - path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_exec/pubspec.yaml b/links/gql_exec/pubspec.yaml index 0a0a583e..68d3e604 100644 --- a/links/gql_exec/pubspec.yaml +++ b/links/gql_exec/pubspec.yaml @@ -11,45 +11,6 @@ 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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - end_to_end_test: - path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_http_link/pubspec.yaml b/links/gql_http_link/pubspec.yaml index 556f46f2..1ed60341 100644 --- a/links/gql_http_link/pubspec.yaml +++ b/links/gql_http_link/pubspec.yaml @@ -17,45 +17,6 @@ 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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - end_to_end_test: - path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_link/pubspec.yaml b/links/gql_link/pubspec.yaml index ae5dc5de..5a951d87 100644 --- a/links/gql_link/pubspec.yaml +++ b/links/gql_link/pubspec.yaml @@ -12,45 +12,6 @@ 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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - end_to_end_test: - path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_transform_link/pubspec.yaml b/links/gql_transform_link/pubspec.yaml index 1ad8136a..5175a77c 100644 --- a/links/gql_transform_link/pubspec.yaml +++ b/links/gql_transform_link/pubspec.yaml @@ -12,45 +12,6 @@ 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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - end_to_end_test: - path: ../../codegen/end_to_end_test topics: - graphql - gql diff --git a/links/gql_websocket_link/pubspec.yaml b/links/gql_websocket_link/pubspec.yaml index f80b069f..f4ee609d 100644 --- a/links/gql_websocket_link/pubspec.yaml +++ b/links/gql_websocket_link/pubspec.yaml @@ -16,45 +16,6 @@ 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_tristate_value: - path: ../../codegen/gql_tristate_value - 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_tristate: - path: ../../codegen/end_to_end_test_tristate - end_to_end_test: - path: ../../codegen/end_to_end_test topics: - graphql - gql From 571b92f68fc7e787b4a790dbdc530b9ff577a5db Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 7 Jan 2024 19:14:53 +0000 Subject: [PATCH 09/12] fmt --- .../fragments_inline_nesting_test.dart | 20 ++++- codegen/gql_build/lib/src/data_builder.dart | 15 +++- codegen/gql_code_builder/lib/data.dart | 3 +- codegen/gql_code_builder/lib/src/common.dart | 13 ++-- .../lib/src/inline_fragment_classes.dart | 40 ++++++---- .../lib/src/operation/data.dart | 73 +++++++++++++------ .../lib/src/when_extension.dart | 47 +++++++----- 7 files changed, 142 insertions(+), 69 deletions(-) diff --git a/codegen/end_to_end_test/test/operation/fragments_inline_nesting_test.dart b/codegen/end_to_end_test/test/operation/fragments_inline_nesting_test.dart index 159276b0..9cfd3500 100644 --- a/codegen/end_to_end_test/test/operation/fragments_inline_nesting_test.dart +++ b/codegen/end_to_end_test/test/operation/fragments_inline_nesting_test.dart @@ -11,7 +11,12 @@ void main() { "name": "Luke", "homePlanet": "Tattoine", "friends": [ - {"__typename": "Droid", "id": "r2d2", "name": "R2-D2", "primaryFunction": "Astromech"}, + { + "__typename": "Droid", + "id": "r2d2", + "name": "R2-D2", + "primaryFunction": "Astromech" + }, { "__typename": "Human", "id": "han", @@ -27,14 +32,16 @@ void main() { expect(gqlHuman?.name, equals("Luke")); expect(gqlHuman?.homePlanet, equals("Tattoine")); - final gqlHuman_droidFriends = gqlHuman?.friends?.whereType(); + 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(); + final gqlHuman_humanFriends = gqlHuman?.friends + ?.whereType(); expect(gqlHuman_humanFriends?.first.id, equals("han")); expect(gqlHuman_humanFriends?.first.name, equals("Han Solo")); @@ -70,7 +77,12 @@ void main() { "name": "Obiwan", "homePlanet": "Stewjon", "friends": [ - {"__typename": "Droid", "id": "r2d2", "name": "R2-D2", "primaryFunction": "Astromech"}, + { + "__typename": "Droid", + "id": "r2d2", + "name": "R2-D2", + "primaryFunction": "Astromech" + }, { "__typename": "Human", "id": "luke", diff --git a/codegen/gql_build/lib/src/data_builder.dart b/codegen/gql_build/lib/src/data_builder.dart index 6c6ff083..641c17a3 100644 --- a/codegen/gql_build/lib/src/data_builder.dart +++ b/codegen/gql_build/lib/src/data_builder.dart @@ -35,10 +35,17 @@ class DataBuilder implements Builder { final doc = await readDocument(buildStep); final schema = await readDocument(buildStep, schemaId); - final generatedPartUrl = buildStep.inputId.changeExtension(generatedFileExtension(dataExtension)).uri.path; - - final library = buildDataLibrary(addTypenames ? introspection.addTypenames(doc) : doc, - introspection.addTypenames(schema), basename(generatedPartUrl), typeOverrides, whenExtensionConfig); + final generatedPartUrl = buildStep.inputId + .changeExtension(generatedFileExtension(dataExtension)) + .uri + .path; + + final library = buildDataLibrary( + addTypenames ? introspection.addTypenames(doc) : doc, + introspection.addTypenames(schema), + basename(generatedPartUrl), + typeOverrides, + whenExtensionConfig); return writeDocument( library, diff --git a/codegen/gql_code_builder/lib/data.dart b/codegen/gql_code_builder/lib/data.dart index 0b9c0174..98d2e056 100644 --- a/codegen/gql_code_builder/lib/data.dart +++ b/codegen/gql_code_builder/lib/data.dart @@ -18,7 +18,8 @@ Library buildDataLibrary( SourceNode schemaSource, String partUrl, Map typeOverrides, [ - InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig = const InlineFragmentSpreadWhenExtensionConfig( + InlineFragmentSpreadWhenExtensionConfig whenExtensionConfig = + const InlineFragmentSpreadWhenExtensionConfig( generateWhenExtensionMethod: false, generateMaybeWhenExtensionMethod: false, ), diff --git a/codegen/gql_code_builder/lib/src/common.dart b/codegen/gql_code_builder/lib/src/common.dart index 33ade380..cc537716 100644 --- a/codegen/gql_code_builder/lib/src/common.dart +++ b/codegen/gql_code_builder/lib/src/common.dart @@ -88,9 +88,11 @@ const defaultTypeMap = { "Boolean": Reference("bool"), }; -Reference _typeRef(TypeNode type, Map typeMap, Reference? fragmentRef) { +Reference _typeRef( + TypeNode type, Map typeMap, Reference? fragmentRef) { if (type is NamedTypeNode) { - final ref = fragmentRef ?? typeMap[type.name.value] ?? Reference(type.name.value); + final ref = + fragmentRef ?? typeMap[type.name.value] ?? Reference(type.name.value); assert(ref.symbol != null, "Symbol for ${ref} must not be null"); return TypeReference( (b) => b @@ -162,12 +164,7 @@ Method buildGetter({ ...typeOverrides, }; - final returnType = - _typeRef( - typeNode, - typeMap, - fragmentRef - ); + final returnType = _typeRef(typeNode, typeMap, fragmentRef); return Method( (b) => b diff --git a/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart b/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart index 647817a3..5ba924de 100644 --- a/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart +++ b/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart @@ -36,7 +36,8 @@ List buildInlineFragmentClasses({ config: whenExtensionConfig, ); - List selectionsForInlineFragment(InlineFragmentNode inlineFragment) { + List selectionsForInlineFragment( + InlineFragmentNode inlineFragment) { final fragSelections = mergeSelections( [ ...selections.whereType(), @@ -49,19 +50,22 @@ List buildInlineFragmentClasses({ return fragSelections; } - Reference? existingFragmentWithSameSelections(String typeName, List fragmentSelections) { + Reference? existingFragmentWithSameSelections( + String typeName, List fragmentSelections) { final existing = fragmentRefMap[( typeName, BuiltSet.of( fragmentSelections.withoutFragmentSpreads, ) )]; - print("existing: $existing on $typeName with selections: $fragmentSelections"); + print( + "existing: $existing on $typeName with selections: $fragmentSelections"); return existing; } List buildSelectionSetClassesForInlineFragment( - InlineFragmentNode inlineFragment, List fragmentSelections) => + InlineFragmentNode inlineFragment, + List fragmentSelections) => buildSelectionSetDataClasses( name: _inlineFragmentName(name, inlineFragment), selections: fragmentSelections, @@ -83,7 +87,8 @@ List buildInlineFragmentClasses({ ...selections.whereType(), ], fragmentMap, true); - final existingFragment = existingFragmentWithSameSelections(type, baseSelections); + final existingFragment = + existingFragmentWithSameSelections(type, baseSelections); if (existingFragment != null) { final existingFragmentName = existingFragment.symbol; @@ -95,7 +100,8 @@ List buildInlineFragmentClasses({ return []; } else { - print("&&&&&&& no existing fragment found for $name on $type with selections: $baseSelections"); + print( + "&&&&&&& no existing fragment found for $name on $type with selections: $baseSelections"); } return [ @@ -106,7 +112,9 @@ List buildInlineFragmentClasses({ schemaSource: schemaSource, type: type, typeOverrides: typeOverrides, - superclassSelections: {name: SourceSelections(url: null, selections: selections)}, + superclassSelections: { + name: SourceSelections(url: null, selections: selections) + }, built: built, whenExtensionConfig: whenExtensionConfig, fragmentRefMap: fragmentRefMap, @@ -155,11 +163,13 @@ List buildInlineFragmentClasses({ ) .expand( (fragmentWithSelections) { - final (:inlineFragment, selections: fragmentSelections) = fragmentWithSelections; + final (:inlineFragment, selections: fragmentSelections) = + fragmentWithSelections; final typeName = inlineFragment.typeCondition!.on.name.value; - final existingFragment = existingFragmentWithSameSelections(typeName, fragmentSelections); + final existingFragment = + existingFragmentWithSameSelections(typeName, fragmentSelections); if (existingFragment != null) { final existingFragmentName = existingFragment.symbol; @@ -181,7 +191,8 @@ List buildInlineFragmentClasses({ ]; } -String _inlineFragmentName(String baseName, InlineFragmentNode inlineFragment) => +String _inlineFragmentName( + String baseName, InlineFragmentNode inlineFragment) => "${baseName}__as${inlineFragment.typeCondition!.on.name.value}"; String _inlineFragmentBaseName(String baseName) => "${baseName}__base"; @@ -194,7 +205,8 @@ List _inlineFragmentRootSerializationMethods({ final toJson = buildToJsonGetter(name); final fromJson = buildFromJsonGetter(name); - final inlineSerializer = _inlineFragmentSerializer(name, inlineFragments, fragmentRefMap); + final inlineSerializer = + _inlineFragmentSerializer(name, inlineFragments, fragmentRefMap); return [ inlineSerializer, @@ -214,7 +226,8 @@ Method _inlineFragmentSerializer( (b) => b ..body = TypeReference((b) => b ..symbol = "InlineFragmentSerializer" - ..url = "package:gql_code_builder/src/serializers/inline_fragment_serializer.dart" + ..url = + "package:gql_code_builder/src/serializers/inline_fragment_serializer.dart" ..types.add(refer(name))).call([ literalString(name), refer(_inlineFragmentBaseName(name)), @@ -222,7 +235,8 @@ Method _inlineFragmentSerializer( /// TODO: Handle inline fragments without a type condition /// https://spec.graphql.org/June2018/#sec-Inline-Fragments { - for (final v in inlineFragments.where((frag) => frag.typeCondition != null)) + for (final v + in inlineFragments.where((frag) => frag.typeCondition != null)) "${v.typeCondition!.on.name.value}": refer( _inlineFragmentName(name, v), ) diff --git a/codegen/gql_code_builder/lib/src/operation/data.dart b/codegen/gql_code_builder/lib/src/operation/data.dart index dd6a5d51..6cb902d7 100644 --- a/codegen/gql_code_builder/lib/src/operation/data.dart +++ b/codegen/gql_code_builder/lib/src/operation/data.dart @@ -49,7 +49,8 @@ List buildFragmentDataClasses( Map> possibleTypesMap, ) { final fragmentMap = _fragmentMap(docSource); - final selections = mergeSelections(frag.selectionSet.selections, fragmentMap, true); + final selections = + mergeSelections(frag.selectionSet.selections, fragmentMap, true); final set = BuiltSet.of(selections.withoutFragmentSpreads); @@ -129,7 +130,8 @@ String _operationType( } Map _fragmentMap(SourceNode source) => { - for (final def in source.document.definitions.whereType()) + for (final def + in source.document.definitions.whereType()) def.name.value: SourceSelections( url: source.url, selections: def.selectionSet.selections, @@ -160,7 +162,8 @@ List buildSelectionSetDataClasses({ }) { for (final selection in selections.whereType()) { if (!fragmentMap.containsKey(selection.name.value)) { - throw Exception("Couldn't find fragment definition for fragment spread '${selection.name.value}'"); + throw Exception( + "Couldn't find fragment definition for fragment spread '${selection.name.value}'"); } superclassSelections["${selection.name.value}"] = SourceSelections( url: fragmentMap[selection.name.value]!.url, @@ -173,7 +176,9 @@ List buildSelectionSetDataClasses({ final canonicalSelections = BuiltSet.of(selections.withoutFragmentSpreads); - final superclassSelectionNodes = superclassSelections.values.expand((selections) => selections.selections).toSet(); + final superclassSelectionNodes = superclassSelections.values + .expand((selections) => selections.selections) + .toSet(); final fieldsThatAreSingleFragmentSpreads = {}; @@ -199,10 +204,12 @@ List buildSelectionSetDataClasses({ ]; if (node.name.value == "hero") { - print("mergedGetterSelections: $mergedGetterSelections from ${getterSelections.selections}"); + print( + "mergedGetterSelections: $mergedGetterSelections from ${getterSelections.selections}"); } - final withoutFragmentSpreads = mergedGetterSelections.withoutFragmentSpreads.toBuiltSet(); + final withoutFragmentSpreads = + mergedGetterSelections.withoutFragmentSpreads.toBuiltSet(); final fieldTypeDefNode = getTypeDefinitionNode( schemaSource.document, @@ -210,10 +217,14 @@ List buildSelectionSetDataClasses({ ); if (fieldTypeDefNode == null) { - throw Exception("Couldn't find type definition for ${unwrapTypeNode(typeNode).name.value}"); + throw Exception( + "Couldn't find type definition for ${unwrapTypeNode(typeNode).name.value}"); } - final hasMatchingFragment = fragmentRefMap[(fieldTypeDefNode.name.value, withoutFragmentSpreads)]; + final hasMatchingFragment = fragmentRefMap[( + fieldTypeDefNode.name.value, + withoutFragmentSpreads + )]; if (hasMatchingFragment != null) { fieldsThatAreSingleFragmentSpreads.add(node); @@ -287,7 +298,8 @@ List buildSelectionSetDataClasses({ name: name, getters: fieldGetters, initializers: { - if (fieldGetters.any((getter) => getter.name == "G__typename")) "G__typename": literalString(type), + if (fieldGetters.any((getter) => getter.name == "G__typename")) + "G__typename": literalString(type), }, superclassSelections: superclassSelections, ), @@ -295,7 +307,9 @@ List buildSelectionSetDataClasses({ ...selections .whereType() .where( - (field) => field.selectionSet != null && !fieldsThatAreSingleFragmentSpreads.contains(field), + (field) => + field.selectionSet != null && + !fieldsThatAreSingleFragmentSpreads.contains(field), ) .expand( (field) => buildSelectionSetDataClasses( @@ -326,7 +340,8 @@ List buildSelectionSetDataClasses({ } /// Deeply merges field nodes -List mergeSelections(List selections, Map fragmentMap, +List mergeSelections(List selections, + Map fragmentMap, [bool keepInlineFragments = true]) => _expandFragmentSpreads(selections, fragmentMap, keepInlineFragments) .fold>( @@ -338,7 +353,8 @@ List mergeSelections(List selections, Map[]; selectionMap[key] = FieldNode( @@ -346,7 +362,10 @@ List mergeSelections(List selections, Map _expandFragmentSpreads( ); } - final fragmentSelections = fragmentMap[selection.name.value]!.selections; + final fragmentSelections = + fragmentMap[selection.name.value]!.selections; return [ if (retainFragmentSpreads) selection, @@ -388,7 +408,8 @@ List _expandFragmentSpreads( [ ...fragmentSelections.whereType(), ...fragmentSelections.whereType(), - if (keepInlineFragments) ...fragmentSelections.whereType(), + if (keepInlineFragments) + ...fragmentSelections.whereType(), ], fragmentMap, keepInlineFragments, @@ -419,7 +440,9 @@ Map _fragmentSelectionsForField( "${entry.key}_${field.alias?.value ?? field.name.value}", SourceSelections( url: entry.value.url, - selections: selection.selectionSet!.selections.whereType().toList(), + selections: selection.selectionSet!.selections + .whereType() + .toList(), ), ), ), @@ -443,7 +466,8 @@ TypeNode _getFieldTypeNode( } else if (node is InterfaceTypeDefinitionNode) { fields = node.fields; } else { - throw Exception("${node.name.value} is not an ObjectTypeDefinitionNode or InterfaceTypeDefinitionNode"); + throw Exception( + "${node.name.value} is not an ObjectTypeDefinitionNode or InterfaceTypeDefinitionNode"); } return fields .firstWhere( @@ -453,15 +477,18 @@ TypeNode _getFieldTypeNode( } extension IsSingleFragmentSpread on SelectionSetNode { - Iterable get fragmentSpreads => selections.whereType(); + Iterable get fragmentSpreads => + selections.whereType(); - Iterable get inlineFragments => selections.whereType(); + Iterable get inlineFragments => + selections.whereType(); Iterable get fields => selections.whereType(); } extension WithoutFragmentSpreads on Iterable { - Iterable get withoutFragmentSpreads => where((selection) => selection is! FragmentSpreadNode).map((e) { + Iterable get withoutFragmentSpreads => + where((selection) => selection is! FragmentSpreadNode).map((e) { if (e is FieldNode) { if (e.selectionSet == null) return e; return FieldNode( @@ -470,7 +497,8 @@ extension WithoutFragmentSpreads on Iterable { arguments: e.arguments, directives: e.directives, selectionSet: SelectionSetNode( - selections: e.selectionSet!.selections.withoutFragmentSpreads.toList(), + selections: + e.selectionSet!.selections.withoutFragmentSpreads.toList(), ), ); } @@ -479,7 +507,8 @@ extension WithoutFragmentSpreads on Iterable { typeCondition: e.typeCondition, directives: e.directives, selectionSet: SelectionSetNode( - selections: e.selectionSet.selections.withoutFragmentSpreads.toList(), + selections: + e.selectionSet.selections.withoutFragmentSpreads.toList(), ), ); } diff --git a/codegen/gql_code_builder/lib/src/when_extension.dart b/codegen/gql_code_builder/lib/src/when_extension.dart index 0813c667..52987e54 100644 --- a/codegen/gql_code_builder/lib/src/when_extension.dart +++ b/codegen/gql_code_builder/lib/src/when_extension.dart @@ -7,9 +7,11 @@ import "package:gql_code_builder/src/utils/uncapitalize.dart"; // static building blocks for the generated code final _genericTypeParam = TypeReference((b) => b..symbol = "_T"); -final _orElseFunctionType = FunctionType((b) => b..returnType = _genericTypeParam); +final _orElseFunctionType = + FunctionType((b) => b..returnType = _genericTypeParam); -String _getSchemaTypeName(InlineFragmentNode node) => node.typeCondition!.on.name.value; +String _getSchemaTypeName(InlineFragmentNode node) => + node.typeCondition!.on.name.value; final _orElseFunctionRef = refer("orElse"); final _orElseInvocation = _orElseFunctionRef.call([]); @@ -26,7 +28,8 @@ final _curlyBracketOpen = Code("{"); final _curlyBracketClose = Code("}"); -Code _caseStatement(InlineFragmentNode inlineFragment) => Code("case '${_getSchemaTypeName(inlineFragment)}': "); +Code _caseStatement(InlineFragmentNode inlineFragment) => + Code("case '${_getSchemaTypeName(inlineFragment)}': "); /// returns an Extension that implements the `when` method and/or the `maybeWhen` method /// that makes it more convenient to use the union types or interfaces without resorting to @@ -37,11 +40,13 @@ Extension? inlineFragmentWhenExtension( {required String baseTypeName, required List inlineFragments, required InlineFragmentSpreadWhenExtensionConfig config}) { - final inlineFragmentsWithTypConditions = - inlineFragments.where((inlineFragment) => inlineFragment.typeCondition != null).toList(); + final inlineFragmentsWithTypConditions = inlineFragments + .where((inlineFragment) => inlineFragment.typeCondition != null) + .toList(); final nothingToDo = inlineFragmentsWithTypConditions.isEmpty || - (!config.generateWhenExtensionMethod && !config.generateMaybeWhenExtensionMethod); + (!config.generateWhenExtensionMethod && + !config.generateMaybeWhenExtensionMethod); if (nothingToDo) { return null; @@ -54,7 +59,10 @@ Extension? inlineFragmentWhenExtension( /// a pool of parameter names which have already been used /// so we can avoid name clashes - final Set usedParameterNames = {_orElseFunctionRef.symbol!, _genericTypeParam.symbol}; + final Set usedParameterNames = { + _orElseFunctionRef.symbol!, + _genericTypeParam.symbol + }; final Map parameterNamesPerInlineNode = {}; @@ -64,7 +72,8 @@ Extension? inlineFragmentWhenExtension( /// example: if the typeCondition is "Human", the parameter name will be "human" /// if the typeCondition is "Human" and "human" is already taken, the parameter name will be "ghuman" /// if the typeCondition is "orElse", the parameter name will be "gorElse" because "orElse" is reserved - String getParameterName(InlineFragmentNode node) => parameterNamesPerInlineNode.putIfAbsent(node, () { + String getParameterName(InlineFragmentNode node) => + parameterNamesPerInlineNode.putIfAbsent(node, () { var name = identifier(uncapitalize(_getSchemaTypeName(node))); while (usedParameterNames.contains(name)) { @@ -114,7 +123,8 @@ Extension? inlineFragmentWhenExtension( ..name = getParameterName(inlineFragment) ..type = FunctionType((b) => b ..returnType = _genericTypeParam - ..requiredParameters.add(Reference(getGeneratedTypeName(inlineFragment)))) + ..requiredParameters + .add(Reference(getGeneratedTypeName(inlineFragment)))) ..named = true ..required = true), ), @@ -131,10 +141,11 @@ Extension? inlineFragmentWhenExtension( ..body = Block.of([ _switchTypeName, _curlyBracketOpen, - ...inlineFragmentsWithTypConditions.map((inlineFragment) => Block.of([ - _caseStatement(inlineFragment), - whenCaseBody(inlineFragment), - ])), + ...inlineFragmentsWithTypConditions + .map((inlineFragment) => Block.of([ + _caseStatement(inlineFragment), + whenCaseBody(inlineFragment), + ])), _defaultCallOrElse, _curlyBracketClose, ])), @@ -172,10 +183,12 @@ Extension? inlineFragmentWhenExtension( [ _switchTypeName, _curlyBracketOpen, - ...inlineFragments.where((element) => element.typeCondition != null).map((inlineFragment) => Block.of([ - _caseStatement(inlineFragment), - maybeWhenCaseBody(inlineFragment), - ])), + ...inlineFragments + .where((element) => element.typeCondition != null) + .map((inlineFragment) => Block.of([ + _caseStatement(inlineFragment), + maybeWhenCaseBody(inlineFragment), + ])), _defaultCallOrElse, _curlyBracketClose, ], From 338b6d26c51f03568430814184e4f4358a9a8ad6 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 7 Jan 2024 22:07:58 +0000 Subject: [PATCH 10/12] add repro for case that does not work --- .../fragment_activities.ast.gql.dart | 166 ++ .../fragment_activities.data.gql.dart | 485 +++++ .../fragment_activities.data.gql.g.dart | 1561 +++++++++++++++++ .../fragment_activities.var.gql.dart | 117 ++ .../fragment_activities.var.gql.g.dart | 414 +++++ .../lib/fragments/fragment_activities.graphql | 33 + .../graphql/__generated__/schema.ast.gql.dart | 163 ++ .../__generated__/schema.schema.gql.dart | 1 + .../__generated__/serializers.gql.dart | 36 + .../__generated__/serializers.gql.g.dart | 19 + .../lib/graphql/schema.graphql | 289 +-- .../test/operation/fragments_test.dart | 4 +- .../lib/src/inline_fragment_classes.dart | 53 +- 13 files changed, 3179 insertions(+), 162 deletions(-) create mode 100644 codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.ast.gql.dart create mode 100644 codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.data.gql.dart create mode 100644 codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.data.gql.g.dart create mode 100644 codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.var.gql.dart create mode 100644 codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.var.gql.g.dart create mode 100644 codegen/end_to_end_test/lib/fragments/fragment_activities.graphql diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.ast.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.ast.gql.dart new file mode 100644 index 00000000..a8031344 --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.ast.gql.dart @@ -0,0 +1,166 @@ +// 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 ActivityA = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'ActivityA'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ActivityA'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'activityData'), + alias: null, + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), + ), + ]), +); +const ActivityB = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'ActivityB'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ActivityB'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'activity'), + alias: null, + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.InlineFragmentNode( + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ActivityA'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'ActivityA'), + directives: [], + ) + ]), + ), + ]), + ), + ]), +); +const Item = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'Item'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Item'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), +); +const ItemConnection = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'ItemConnection'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ItemConnection'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'count'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ), + _i1.FieldNode( + name: _i1.NameNode(value: 'edges'), + alias: null, + arguments: [], + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FragmentSpreadNode( + name: _i1.NameNode(value: 'ItemEdge'), + directives: [], + ) + ]), + ), + ]), +); +const ItemEdge = _i1.FragmentDefinitionNode( + name: _i1.NameNode(value: 'ItemEdge'), + typeCondition: _i1.TypeConditionNode( + on: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ItemEdge'), + isNonNull: false, + )), + directives: [], + selectionSet: _i1.SelectionSetNode(selections: [ + _i1.FieldNode( + name: _i1.NameNode(value: '__typename'), + alias: null, + arguments: [], + directives: [], + selectionSet: null, + ) + ]), +); +const document = _i1.DocumentNode(definitions: [ + ActivityA, + ActivityB, + Item, + ItemConnection, + ItemEdge, +]); diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.data.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.data.gql.dart new file mode 100644 index 00000000..060bb30d --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.data.gql.dart @@ -0,0 +1,485 @@ +// 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/graphql/__generated__/serializers.gql.dart' + as _i1; +import 'package:gql_code_builder/src/serializers/inline_fragment_serializer.dart' + as _i2; + +part 'fragment_activities.data.gql.g.dart'; + +abstract class GActivityA { + String get G__typename; + GActivityA_activityData? get activityData; + Map toJson(); +} + +abstract class GActivityA_activityData { + String get G__typename; + Map toJson(); +} + +abstract class GActivityAData + implements Built, GActivityA { + GActivityAData._(); + + factory GActivityAData([void Function(GActivityADataBuilder b) updates]) = + _$GActivityAData; + + static void _initializeBuilder(GActivityADataBuilder b) => + b..G__typename = 'ActivityA'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + GActivityAData_activityData? get activityData; + static Serializer get serializer => + _$gActivityADataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GActivityAData.serializer, + this, + ) as Map); + + static GActivityAData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GActivityAData.serializer, + json, + ); +} + +abstract class GActivityAData_activityData + implements + Built, + GActivityA_activityData { + GActivityAData_activityData._(); + + factory GActivityAData_activityData( + [void Function(GActivityAData_activityDataBuilder b) updates]) = + _$GActivityAData_activityData; + + static void _initializeBuilder(GActivityAData_activityDataBuilder b) => + b..G__typename = 'ActivityUnion'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + static Serializer get serializer => + _$gActivityADataActivityDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GActivityAData_activityData.serializer, + this, + ) as Map); + + static GActivityAData_activityData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GActivityAData_activityData.serializer, + json, + ); +} + +abstract class GActivityB { + String get G__typename; + GActivityB_activity? get activity; + Map toJson(); +} + +abstract class GActivityB_activity { + String get G__typename; +} + +extension GActivityB_activityWhenExtension on GActivityB_activity { + _T when<_T>({ + required _T Function(GActivityB_activity__asActivityA) activityA, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'ActivityA': + return activityA((this as GActivityB_activity__asActivityA)); + default: + return orElse(); + } + } + + _T maybeWhen<_T>({ + _T Function(GActivityB_activity__asActivityA)? activityA, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'ActivityA': + return activityA != null + ? activityA((this as GActivityB_activity__asActivityA)) + : orElse(); + default: + return orElse(); + } + } +} + +abstract class GActivityB_activity__base implements GActivityB_activity { + @override + String get G__typename; + @override + Map toJson(); +} + +abstract class GActivityB_activity__asActivityA + implements GActivityB_activity, GActivityA { + @override + String get G__typename; + @override + GActivityB_activity__asActivityA_activityData? get activityData; + @override + Map toJson(); +} + +abstract class GActivityB_activity__asActivityA_activityData + implements GActivityA_activityData { + @override + String get G__typename; + @override + Map toJson(); +} + +abstract class GActivityBData + implements Built, GActivityB { + GActivityBData._(); + + factory GActivityBData([void Function(GActivityBDataBuilder b) updates]) = + _$GActivityBData; + + static void _initializeBuilder(GActivityBDataBuilder b) => + b..G__typename = 'ActivityB'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + GActivityBData_activity? get activity; + static Serializer get serializer => + _$gActivityBDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GActivityBData.serializer, + this, + ) as Map); + + static GActivityBData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GActivityBData.serializer, + json, + ); +} + +abstract class GActivityBData_activity implements GActivityB_activity { + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + static Serializer get serializer => + _i2.InlineFragmentSerializer( + 'GActivityBData_activity', + GActivityBData_activity__base, + {'ActivityA': GActivityBData_activity__asActivityA}, + ); + + Map toJson() => (_i1.serializers.serializeWith( + GActivityBData_activity.serializer, + this, + ) as Map); + + static GActivityBData_activity? fromJson(Map json) => + _i1.serializers.deserializeWith( + GActivityBData_activity.serializer, + json, + ); +} + +extension GActivityBData_activityWhenExtension on GActivityBData_activity { + _T when<_T>({ + required _T Function(GActivityBData_activity__asActivityA) activityA, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'ActivityA': + return activityA((this as GActivityBData_activity__asActivityA)); + default: + return orElse(); + } + } + + _T maybeWhen<_T>({ + _T Function(GActivityBData_activity__asActivityA)? activityA, + required _T Function() orElse, + }) { + switch (G__typename) { + case 'ActivityA': + return activityA != null + ? activityA((this as GActivityBData_activity__asActivityA)) + : orElse(); + default: + return orElse(); + } + } +} + +abstract class GActivityBData_activity__base + implements + Built, + GActivityBData_activity { + GActivityBData_activity__base._(); + + factory GActivityBData_activity__base( + [void Function(GActivityBData_activity__baseBuilder b) updates]) = + _$GActivityBData_activity__base; + + static void _initializeBuilder(GActivityBData_activity__baseBuilder b) => + b..G__typename = 'ActivityUnion'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + static Serializer get serializer => + _$gActivityBDataActivityBaseSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GActivityBData_activity__base.serializer, + this, + ) as Map); + + static GActivityBData_activity__base? fromJson(Map json) => + _i1.serializers.deserializeWith( + GActivityBData_activity__base.serializer, + json, + ); +} + +abstract class GActivityBData_activity__asActivityA + implements + Built, + GActivityBData_activity, + GActivityA { + GActivityBData_activity__asActivityA._(); + + factory GActivityBData_activity__asActivityA( + [void Function(GActivityBData_activity__asActivityABuilder b) + updates]) = _$GActivityBData_activity__asActivityA; + + static void _initializeBuilder( + GActivityBData_activity__asActivityABuilder b) => + b..G__typename = 'ActivityA'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + GActivityBData_activity__asActivityA_activityData? get activityData; + static Serializer get serializer => + _$gActivityBDataActivityAsActivityASerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GActivityBData_activity__asActivityA.serializer, + this, + ) as Map); + + static GActivityBData_activity__asActivityA? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GActivityBData_activity__asActivityA.serializer, + json, + ); +} + +abstract class GActivityBData_activity__asActivityA_activityData + implements + Built, + GActivityA_activityData { + GActivityBData_activity__asActivityA_activityData._(); + + factory GActivityBData_activity__asActivityA_activityData( + [void Function(GActivityBData_activity__asActivityA_activityDataBuilder b) + updates]) = _$GActivityBData_activity__asActivityA_activityData; + + static void _initializeBuilder( + GActivityBData_activity__asActivityA_activityDataBuilder b) => + b..G__typename = 'ActivityUnion'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + static Serializer + get serializer => + _$gActivityBDataActivityAsActivityAActivityDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GActivityBData_activity__asActivityA_activityData.serializer, + this, + ) as Map); + + static GActivityBData_activity__asActivityA_activityData? fromJson( + Map json) => + _i1.serializers.deserializeWith( + GActivityBData_activity__asActivityA_activityData.serializer, + json, + ); +} + +abstract class GItem { + String get G__typename; + Map toJson(); +} + +abstract class GItemData implements Built, GItem { + GItemData._(); + + factory GItemData([void Function(GItemDataBuilder b) updates]) = _$GItemData; + + static void _initializeBuilder(GItemDataBuilder b) => b..G__typename = 'Item'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + static Serializer get serializer => _$gItemDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GItemData.serializer, + this, + ) as Map); + + static GItemData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GItemData.serializer, + json, + ); +} + +abstract class GItemConnection { + String get G__typename; + int get count; + BuiltList get edges; + Map toJson(); +} + +abstract class GItemConnection_edges implements GItemEdge { + @override + String get G__typename; + @override + Map toJson(); +} + +abstract class GItemConnectionData + implements + Built, + GItemConnection { + GItemConnectionData._(); + + factory GItemConnectionData( + [void Function(GItemConnectionDataBuilder b) updates]) = + _$GItemConnectionData; + + static void _initializeBuilder(GItemConnectionDataBuilder b) => + b..G__typename = 'ItemConnection'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + @override + int get count; + @override + BuiltList get edges; + static Serializer get serializer => + _$gItemConnectionDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GItemConnectionData.serializer, + this, + ) as Map); + + static GItemConnectionData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GItemConnectionData.serializer, + json, + ); +} + +abstract class GItemConnectionData_edges + implements + Built, + GItemConnection_edges, + GItemEdge { + GItemConnectionData_edges._(); + + factory GItemConnectionData_edges( + [void Function(GItemConnectionData_edgesBuilder b) updates]) = + _$GItemConnectionData_edges; + + static void _initializeBuilder(GItemConnectionData_edgesBuilder b) => + b..G__typename = 'ItemEdge'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + static Serializer get serializer => + _$gItemConnectionDataEdgesSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GItemConnectionData_edges.serializer, + this, + ) as Map); + + static GItemConnectionData_edges? fromJson(Map json) => + _i1.serializers.deserializeWith( + GItemConnectionData_edges.serializer, + json, + ); +} + +abstract class GItemEdge { + String get G__typename; + Map toJson(); +} + +abstract class GItemEdgeData + implements Built, GItemEdge { + GItemEdgeData._(); + + factory GItemEdgeData([void Function(GItemEdgeDataBuilder b) updates]) = + _$GItemEdgeData; + + static void _initializeBuilder(GItemEdgeDataBuilder b) => + b..G__typename = 'ItemEdge'; + + @override + @BuiltValueField(wireName: '__typename') + String get G__typename; + static Serializer get serializer => _$gItemEdgeDataSerializer; + + @override + Map toJson() => (_i1.serializers.serializeWith( + GItemEdgeData.serializer, + this, + ) as Map); + + static GItemEdgeData? fromJson(Map json) => + _i1.serializers.deserializeWith( + GItemEdgeData.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.data.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.data.gql.g.dart new file mode 100644 index 00000000..93294e8d --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.data.gql.g.dart @@ -0,0 +1,1561 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fragment_activities.data.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gActivityADataSerializer = + new _$GActivityADataSerializer(); +Serializer _$gActivityADataActivityDataSerializer = + new _$GActivityAData_activityDataSerializer(); +Serializer _$gActivityBDataSerializer = + new _$GActivityBDataSerializer(); +Serializer + _$gActivityBDataActivityBaseSerializer = + new _$GActivityBData_activity__baseSerializer(); +Serializer + _$gActivityBDataActivityAsActivityASerializer = + new _$GActivityBData_activity__asActivityASerializer(); +Serializer + _$gActivityBDataActivityAsActivityAActivityDataSerializer = + new _$GActivityBData_activity__asActivityA_activityDataSerializer(); +Serializer _$gItemDataSerializer = new _$GItemDataSerializer(); +Serializer _$gItemConnectionDataSerializer = + new _$GItemConnectionDataSerializer(); +Serializer _$gItemConnectionDataEdgesSerializer = + new _$GItemConnectionData_edgesSerializer(); +Serializer _$gItemEdgeDataSerializer = + new _$GItemEdgeDataSerializer(); + +class _$GActivityADataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GActivityAData, _$GActivityAData]; + @override + final String wireName = 'GActivityAData'; + + @override + Iterable serialize(Serializers serializers, GActivityAData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.activityData; + if (value != null) { + result + ..add('activityData') + ..add(serializers.serialize(value, + specifiedType: const FullType(GActivityAData_activityData))); + } + return result; + } + + @override + GActivityAData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GActivityADataBuilder(); + + 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 'activityData': + result.activityData.replace(serializers.deserialize(value, + specifiedType: const FullType(GActivityAData_activityData))! + as GActivityAData_activityData); + break; + } + } + + return result.build(); + } +} + +class _$GActivityAData_activityDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GActivityAData_activityData, + _$GActivityAData_activityData + ]; + @override + final String wireName = 'GActivityAData_activityData'; + + @override + Iterable serialize( + Serializers serializers, GActivityAData_activityData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GActivityAData_activityData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GActivityAData_activityDataBuilder(); + + 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 _$GActivityBDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GActivityBData, _$GActivityBData]; + @override + final String wireName = 'GActivityBData'; + + @override + Iterable serialize(Serializers serializers, GActivityBData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.activity; + if (value != null) { + result + ..add('activity') + ..add(serializers.serialize(value, + specifiedType: const FullType(GActivityBData_activity))); + } + return result; + } + + @override + GActivityBData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GActivityBDataBuilder(); + + 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 'activity': + result.activity = serializers.deserialize(value, + specifiedType: const FullType(GActivityBData_activity)) + as GActivityBData_activity?; + break; + } + } + + return result.build(); + } +} + +class _$GActivityBData_activity__baseSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GActivityBData_activity__base, + _$GActivityBData_activity__base + ]; + @override + final String wireName = 'GActivityBData_activity__base'; + + @override + Iterable serialize( + Serializers serializers, GActivityBData_activity__base object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GActivityBData_activity__base deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GActivityBData_activity__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 _$GActivityBData_activity__asActivityASerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GActivityBData_activity__asActivityA, + _$GActivityBData_activity__asActivityA + ]; + @override + final String wireName = 'GActivityBData_activity__asActivityA'; + + @override + Iterable serialize( + Serializers serializers, GActivityBData_activity__asActivityA object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + Object? value; + value = object.activityData; + if (value != null) { + result + ..add('activityData') + ..add(serializers.serialize(value, + specifiedType: const FullType( + GActivityBData_activity__asActivityA_activityData))); + } + return result; + } + + @override + GActivityBData_activity__asActivityA deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GActivityBData_activity__asActivityABuilder(); + + 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 'activityData': + result.activityData.replace(serializers.deserialize(value, + specifiedType: const FullType( + GActivityBData_activity__asActivityA_activityData))! + as GActivityBData_activity__asActivityA_activityData); + break; + } + } + + return result.build(); + } +} + +class _$GActivityBData_activity__asActivityA_activityDataSerializer + implements + StructuredSerializer< + GActivityBData_activity__asActivityA_activityData> { + @override + final Iterable types = const [ + GActivityBData_activity__asActivityA_activityData, + _$GActivityBData_activity__asActivityA_activityData + ]; + @override + final String wireName = 'GActivityBData_activity__asActivityA_activityData'; + + @override + Iterable serialize(Serializers serializers, + GActivityBData_activity__asActivityA_activityData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GActivityBData_activity__asActivityA_activityData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = + new GActivityBData_activity__asActivityA_activityDataBuilder(); + + 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 _$GItemDataSerializer implements StructuredSerializer { + @override + final Iterable types = const [GItemData, _$GItemData]; + @override + final String wireName = 'GItemData'; + + @override + Iterable serialize(Serializers serializers, GItemData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GItemData deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GItemDataBuilder(); + + 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 _$GItemConnectionDataSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GItemConnectionData, + _$GItemConnectionData + ]; + @override + final String wireName = 'GItemConnectionData'; + + @override + Iterable serialize( + Serializers serializers, GItemConnectionData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + 'count', + serializers.serialize(object.count, specifiedType: const FullType(int)), + 'edges', + serializers.serialize(object.edges, + specifiedType: const FullType( + BuiltList, const [const FullType(GItemConnectionData_edges)])), + ]; + + return result; + } + + @override + GItemConnectionData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GItemConnectionDataBuilder(); + + 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 'count': + result.count = 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(GItemConnectionData_edges) + ]))! as BuiltList); + break; + } + } + + return result.build(); + } +} + +class _$GItemConnectionData_edgesSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GItemConnectionData_edges, + _$GItemConnectionData_edges + ]; + @override + final String wireName = 'GItemConnectionData_edges'; + + @override + Iterable serialize( + Serializers serializers, GItemConnectionData_edges object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GItemConnectionData_edges deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GItemConnectionData_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; + } + } + + return result.build(); + } +} + +class _$GItemEdgeDataSerializer implements StructuredSerializer { + @override + final Iterable types = const [GItemEdgeData, _$GItemEdgeData]; + @override + final String wireName = 'GItemEdgeData'; + + @override + Iterable serialize(Serializers serializers, GItemEdgeData object, + {FullType specifiedType = FullType.unspecified}) { + final result = [ + '__typename', + serializers.serialize(object.G__typename, + specifiedType: const FullType(String)), + ]; + + return result; + } + + @override + GItemEdgeData deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GItemEdgeDataBuilder(); + + 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 _$GActivityAData extends GActivityAData { + @override + final String G__typename; + @override + final GActivityAData_activityData? activityData; + + factory _$GActivityAData([void Function(GActivityADataBuilder)? updates]) => + (new GActivityADataBuilder()..update(updates))._build(); + + _$GActivityAData._({required this.G__typename, this.activityData}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GActivityAData', 'G__typename'); + } + + @override + GActivityAData rebuild(void Function(GActivityADataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GActivityADataBuilder toBuilder() => + new GActivityADataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GActivityAData && + G__typename == other.G__typename && + activityData == other.activityData; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, activityData.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GActivityAData') + ..add('G__typename', G__typename) + ..add('activityData', activityData)) + .toString(); + } +} + +class GActivityADataBuilder + implements Builder { + _$GActivityAData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GActivityAData_activityDataBuilder? _activityData; + GActivityAData_activityDataBuilder get activityData => + _$this._activityData ??= new GActivityAData_activityDataBuilder(); + set activityData(GActivityAData_activityDataBuilder? activityData) => + _$this._activityData = activityData; + + GActivityADataBuilder() { + GActivityAData._initializeBuilder(this); + } + + GActivityADataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _activityData = $v.activityData?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GActivityAData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GActivityAData; + } + + @override + void update(void Function(GActivityADataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GActivityAData build() => _build(); + + _$GActivityAData _build() { + _$GActivityAData _$result; + try { + _$result = _$v ?? + new _$GActivityAData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GActivityAData', 'G__typename'), + activityData: _activityData?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'activityData'; + _activityData?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GActivityAData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GActivityAData_activityData extends GActivityAData_activityData { + @override + final String G__typename; + + factory _$GActivityAData_activityData( + [void Function(GActivityAData_activityDataBuilder)? updates]) => + (new GActivityAData_activityDataBuilder()..update(updates))._build(); + + _$GActivityAData_activityData._({required this.G__typename}) : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GActivityAData_activityData', 'G__typename'); + } + + @override + GActivityAData_activityData rebuild( + void Function(GActivityAData_activityDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GActivityAData_activityDataBuilder toBuilder() => + new GActivityAData_activityDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GActivityAData_activityData && + 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'GActivityAData_activityData') + ..add('G__typename', G__typename)) + .toString(); + } +} + +class GActivityAData_activityDataBuilder + implements + Builder { + _$GActivityAData_activityData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GActivityAData_activityDataBuilder() { + GActivityAData_activityData._initializeBuilder(this); + } + + GActivityAData_activityDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _$v = null; + } + return this; + } + + @override + void replace(GActivityAData_activityData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GActivityAData_activityData; + } + + @override + void update(void Function(GActivityAData_activityDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GActivityAData_activityData build() => _build(); + + _$GActivityAData_activityData _build() { + final _$result = _$v ?? + new _$GActivityAData_activityData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GActivityAData_activityData', 'G__typename')); + replace(_$result); + return _$result; + } +} + +class _$GActivityBData extends GActivityBData { + @override + final String G__typename; + @override + final GActivityBData_activity? activity; + + factory _$GActivityBData([void Function(GActivityBDataBuilder)? updates]) => + (new GActivityBDataBuilder()..update(updates))._build(); + + _$GActivityBData._({required this.G__typename, this.activity}) : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GActivityBData', 'G__typename'); + } + + @override + GActivityBData rebuild(void Function(GActivityBDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GActivityBDataBuilder toBuilder() => + new GActivityBDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GActivityBData && + G__typename == other.G__typename && + activity == other.activity; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, activity.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GActivityBData') + ..add('G__typename', G__typename) + ..add('activity', activity)) + .toString(); + } +} + +class GActivityBDataBuilder + implements Builder { + _$GActivityBData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GActivityBData_activity? _activity; + GActivityBData_activity? get activity => _$this._activity; + set activity(GActivityBData_activity? activity) => + _$this._activity = activity; + + GActivityBDataBuilder() { + GActivityBData._initializeBuilder(this); + } + + GActivityBDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _activity = $v.activity; + _$v = null; + } + return this; + } + + @override + void replace(GActivityBData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GActivityBData; + } + + @override + void update(void Function(GActivityBDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GActivityBData build() => _build(); + + _$GActivityBData _build() { + final _$result = _$v ?? + new _$GActivityBData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GActivityBData', 'G__typename'), + activity: activity); + replace(_$result); + return _$result; + } +} + +class _$GActivityBData_activity__base extends GActivityBData_activity__base { + @override + final String G__typename; + + factory _$GActivityBData_activity__base( + [void Function(GActivityBData_activity__baseBuilder)? updates]) => + (new GActivityBData_activity__baseBuilder()..update(updates))._build(); + + _$GActivityBData_activity__base._({required this.G__typename}) : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GActivityBData_activity__base', 'G__typename'); + } + + @override + GActivityBData_activity__base rebuild( + void Function(GActivityBData_activity__baseBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GActivityBData_activity__baseBuilder toBuilder() => + new GActivityBData_activity__baseBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GActivityBData_activity__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'GActivityBData_activity__base') + ..add('G__typename', G__typename)) + .toString(); + } +} + +class GActivityBData_activity__baseBuilder + implements + Builder { + _$GActivityBData_activity__base? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GActivityBData_activity__baseBuilder() { + GActivityBData_activity__base._initializeBuilder(this); + } + + GActivityBData_activity__baseBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _$v = null; + } + return this; + } + + @override + void replace(GActivityBData_activity__base other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GActivityBData_activity__base; + } + + @override + void update(void Function(GActivityBData_activity__baseBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GActivityBData_activity__base build() => _build(); + + _$GActivityBData_activity__base _build() { + final _$result = _$v ?? + new _$GActivityBData_activity__base._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GActivityBData_activity__base', 'G__typename')); + replace(_$result); + return _$result; + } +} + +class _$GActivityBData_activity__asActivityA + extends GActivityBData_activity__asActivityA { + @override + final String G__typename; + @override + final GActivityBData_activity__asActivityA_activityData? activityData; + + factory _$GActivityBData_activity__asActivityA( + [void Function(GActivityBData_activity__asActivityABuilder)? + updates]) => + (new GActivityBData_activity__asActivityABuilder()..update(updates)) + ._build(); + + _$GActivityBData_activity__asActivityA._( + {required this.G__typename, this.activityData}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GActivityBData_activity__asActivityA', 'G__typename'); + } + + @override + GActivityBData_activity__asActivityA rebuild( + void Function(GActivityBData_activity__asActivityABuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GActivityBData_activity__asActivityABuilder toBuilder() => + new GActivityBData_activity__asActivityABuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GActivityBData_activity__asActivityA && + G__typename == other.G__typename && + activityData == other.activityData; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, activityData.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GActivityBData_activity__asActivityA') + ..add('G__typename', G__typename) + ..add('activityData', activityData)) + .toString(); + } +} + +class GActivityBData_activity__asActivityABuilder + implements + Builder { + _$GActivityBData_activity__asActivityA? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GActivityBData_activity__asActivityA_activityDataBuilder? _activityData; + GActivityBData_activity__asActivityA_activityDataBuilder get activityData => + _$this._activityData ??= + new GActivityBData_activity__asActivityA_activityDataBuilder(); + set activityData( + GActivityBData_activity__asActivityA_activityDataBuilder? + activityData) => + _$this._activityData = activityData; + + GActivityBData_activity__asActivityABuilder() { + GActivityBData_activity__asActivityA._initializeBuilder(this); + } + + GActivityBData_activity__asActivityABuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _activityData = $v.activityData?.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GActivityBData_activity__asActivityA other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GActivityBData_activity__asActivityA; + } + + @override + void update( + void Function(GActivityBData_activity__asActivityABuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GActivityBData_activity__asActivityA build() => _build(); + + _$GActivityBData_activity__asActivityA _build() { + _$GActivityBData_activity__asActivityA _$result; + try { + _$result = _$v ?? + new _$GActivityBData_activity__asActivityA._( + G__typename: BuiltValueNullFieldError.checkNotNull(G__typename, + r'GActivityBData_activity__asActivityA', 'G__typename'), + activityData: _activityData?.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'activityData'; + _activityData?.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GActivityBData_activity__asActivityA', + _$failedField, + e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GActivityBData_activity__asActivityA_activityData + extends GActivityBData_activity__asActivityA_activityData { + @override + final String G__typename; + + factory _$GActivityBData_activity__asActivityA_activityData( + [void Function( + GActivityBData_activity__asActivityA_activityDataBuilder)? + updates]) => + (new GActivityBData_activity__asActivityA_activityDataBuilder() + ..update(updates)) + ._build(); + + _$GActivityBData_activity__asActivityA_activityData._( + {required this.G__typename}) + : super._() { + BuiltValueNullFieldError.checkNotNull(G__typename, + r'GActivityBData_activity__asActivityA_activityData', 'G__typename'); + } + + @override + GActivityBData_activity__asActivityA_activityData rebuild( + void Function( + GActivityBData_activity__asActivityA_activityDataBuilder) + updates) => + (toBuilder()..update(updates)).build(); + + @override + GActivityBData_activity__asActivityA_activityDataBuilder toBuilder() => + new GActivityBData_activity__asActivityA_activityDataBuilder() + ..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GActivityBData_activity__asActivityA_activityData && + 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'GActivityBData_activity__asActivityA_activityData') + ..add('G__typename', G__typename)) + .toString(); + } +} + +class GActivityBData_activity__asActivityA_activityDataBuilder + implements + Builder { + _$GActivityBData_activity__asActivityA_activityData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GActivityBData_activity__asActivityA_activityDataBuilder() { + GActivityBData_activity__asActivityA_activityData._initializeBuilder(this); + } + + GActivityBData_activity__asActivityA_activityDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _$v = null; + } + return this; + } + + @override + void replace(GActivityBData_activity__asActivityA_activityData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GActivityBData_activity__asActivityA_activityData; + } + + @override + void update( + void Function(GActivityBData_activity__asActivityA_activityDataBuilder)? + updates) { + if (updates != null) updates(this); + } + + @override + GActivityBData_activity__asActivityA_activityData build() => _build(); + + _$GActivityBData_activity__asActivityA_activityData _build() { + final _$result = _$v ?? + new _$GActivityBData_activity__asActivityA_activityData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, + r'GActivityBData_activity__asActivityA_activityData', + 'G__typename')); + replace(_$result); + return _$result; + } +} + +class _$GItemData extends GItemData { + @override + final String G__typename; + + factory _$GItemData([void Function(GItemDataBuilder)? updates]) => + (new GItemDataBuilder()..update(updates))._build(); + + _$GItemData._({required this.G__typename}) : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GItemData', 'G__typename'); + } + + @override + GItemData rebuild(void Function(GItemDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GItemDataBuilder toBuilder() => new GItemDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GItemData && 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'GItemData') + ..add('G__typename', G__typename)) + .toString(); + } +} + +class GItemDataBuilder implements Builder { + _$GItemData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GItemDataBuilder() { + GItemData._initializeBuilder(this); + } + + GItemDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _$v = null; + } + return this; + } + + @override + void replace(GItemData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GItemData; + } + + @override + void update(void Function(GItemDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GItemData build() => _build(); + + _$GItemData _build() { + final _$result = _$v ?? + new _$GItemData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GItemData', 'G__typename')); + replace(_$result); + return _$result; + } +} + +class _$GItemConnectionData extends GItemConnectionData { + @override + final String G__typename; + @override + final int count; + @override + final BuiltList edges; + + factory _$GItemConnectionData( + [void Function(GItemConnectionDataBuilder)? updates]) => + (new GItemConnectionDataBuilder()..update(updates))._build(); + + _$GItemConnectionData._( + {required this.G__typename, required this.count, required this.edges}) + : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GItemConnectionData', 'G__typename'); + BuiltValueNullFieldError.checkNotNull( + count, r'GItemConnectionData', 'count'); + BuiltValueNullFieldError.checkNotNull( + edges, r'GItemConnectionData', 'edges'); + } + + @override + GItemConnectionData rebuild( + void Function(GItemConnectionDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GItemConnectionDataBuilder toBuilder() => + new GItemConnectionDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GItemConnectionData && + G__typename == other.G__typename && + count == other.count && + edges == other.edges; + } + + @override + int get hashCode { + var _$hash = 0; + _$hash = $jc(_$hash, G__typename.hashCode); + _$hash = $jc(_$hash, count.hashCode); + _$hash = $jc(_$hash, edges.hashCode); + _$hash = $jf(_$hash); + return _$hash; + } + + @override + String toString() { + return (newBuiltValueToStringHelper(r'GItemConnectionData') + ..add('G__typename', G__typename) + ..add('count', count) + ..add('edges', edges)) + .toString(); + } +} + +class GItemConnectionDataBuilder + implements Builder { + _$GItemConnectionData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + int? _count; + int? get count => _$this._count; + set count(int? count) => _$this._count = count; + + ListBuilder? _edges; + ListBuilder get edges => + _$this._edges ??= new ListBuilder(); + set edges(ListBuilder? edges) => + _$this._edges = edges; + + GItemConnectionDataBuilder() { + GItemConnectionData._initializeBuilder(this); + } + + GItemConnectionDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _count = $v.count; + _edges = $v.edges.toBuilder(); + _$v = null; + } + return this; + } + + @override + void replace(GItemConnectionData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GItemConnectionData; + } + + @override + void update(void Function(GItemConnectionDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GItemConnectionData build() => _build(); + + _$GItemConnectionData _build() { + _$GItemConnectionData _$result; + try { + _$result = _$v ?? + new _$GItemConnectionData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GItemConnectionData', 'G__typename'), + count: BuiltValueNullFieldError.checkNotNull( + count, r'GItemConnectionData', 'count'), + edges: edges.build()); + } catch (_) { + late String _$failedField; + try { + _$failedField = 'edges'; + edges.build(); + } catch (e) { + throw new BuiltValueNestedFieldError( + r'GItemConnectionData', _$failedField, e.toString()); + } + rethrow; + } + replace(_$result); + return _$result; + } +} + +class _$GItemConnectionData_edges extends GItemConnectionData_edges { + @override + final String G__typename; + + factory _$GItemConnectionData_edges( + [void Function(GItemConnectionData_edgesBuilder)? updates]) => + (new GItemConnectionData_edgesBuilder()..update(updates))._build(); + + _$GItemConnectionData_edges._({required this.G__typename}) : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GItemConnectionData_edges', 'G__typename'); + } + + @override + GItemConnectionData_edges rebuild( + void Function(GItemConnectionData_edgesBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GItemConnectionData_edgesBuilder toBuilder() => + new GItemConnectionData_edgesBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GItemConnectionData_edges && + 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'GItemConnectionData_edges') + ..add('G__typename', G__typename)) + .toString(); + } +} + +class GItemConnectionData_edgesBuilder + implements + Builder { + _$GItemConnectionData_edges? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GItemConnectionData_edgesBuilder() { + GItemConnectionData_edges._initializeBuilder(this); + } + + GItemConnectionData_edgesBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _$v = null; + } + return this; + } + + @override + void replace(GItemConnectionData_edges other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GItemConnectionData_edges; + } + + @override + void update(void Function(GItemConnectionData_edgesBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GItemConnectionData_edges build() => _build(); + + _$GItemConnectionData_edges _build() { + final _$result = _$v ?? + new _$GItemConnectionData_edges._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GItemConnectionData_edges', 'G__typename')); + replace(_$result); + return _$result; + } +} + +class _$GItemEdgeData extends GItemEdgeData { + @override + final String G__typename; + + factory _$GItemEdgeData([void Function(GItemEdgeDataBuilder)? updates]) => + (new GItemEdgeDataBuilder()..update(updates))._build(); + + _$GItemEdgeData._({required this.G__typename}) : super._() { + BuiltValueNullFieldError.checkNotNull( + G__typename, r'GItemEdgeData', 'G__typename'); + } + + @override + GItemEdgeData rebuild(void Function(GItemEdgeDataBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GItemEdgeDataBuilder toBuilder() => new GItemEdgeDataBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GItemEdgeData && 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'GItemEdgeData') + ..add('G__typename', G__typename)) + .toString(); + } +} + +class GItemEdgeDataBuilder + implements Builder { + _$GItemEdgeData? _$v; + + String? _G__typename; + String? get G__typename => _$this._G__typename; + set G__typename(String? G__typename) => _$this._G__typename = G__typename; + + GItemEdgeDataBuilder() { + GItemEdgeData._initializeBuilder(this); + } + + GItemEdgeDataBuilder get _$this { + final $v = _$v; + if ($v != null) { + _G__typename = $v.G__typename; + _$v = null; + } + return this; + } + + @override + void replace(GItemEdgeData other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GItemEdgeData; + } + + @override + void update(void Function(GItemEdgeDataBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GItemEdgeData build() => _build(); + + _$GItemEdgeData _build() { + final _$result = _$v ?? + new _$GItemEdgeData._( + G__typename: BuiltValueNullFieldError.checkNotNull( + G__typename, r'GItemEdgeData', 'G__typename')); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.var.gql.dart b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.var.gql.dart new file mode 100644 index 00000000..33b41ecf --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.var.gql.dart @@ -0,0 +1,117 @@ +// 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 _i1; + +part 'fragment_activities.var.gql.g.dart'; + +abstract class GActivityAVars + implements Built { + GActivityAVars._(); + + factory GActivityAVars([void Function(GActivityAVarsBuilder b) updates]) = + _$GActivityAVars; + + static Serializer get serializer => + _$gActivityAVarsSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GActivityAVars.serializer, + this, + ) as Map); + + static GActivityAVars? fromJson(Map json) => + _i1.serializers.deserializeWith( + GActivityAVars.serializer, + json, + ); +} + +abstract class GActivityBVars + implements Built { + GActivityBVars._(); + + factory GActivityBVars([void Function(GActivityBVarsBuilder b) updates]) = + _$GActivityBVars; + + static Serializer get serializer => + _$gActivityBVarsSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GActivityBVars.serializer, + this, + ) as Map); + + static GActivityBVars? fromJson(Map json) => + _i1.serializers.deserializeWith( + GActivityBVars.serializer, + json, + ); +} + +abstract class GItemVars implements Built { + GItemVars._(); + + factory GItemVars([void Function(GItemVarsBuilder b) updates]) = _$GItemVars; + + static Serializer get serializer => _$gItemVarsSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GItemVars.serializer, + this, + ) as Map); + + static GItemVars? fromJson(Map json) => + _i1.serializers.deserializeWith( + GItemVars.serializer, + json, + ); +} + +abstract class GItemConnectionVars + implements Built { + GItemConnectionVars._(); + + factory GItemConnectionVars( + [void Function(GItemConnectionVarsBuilder b) updates]) = + _$GItemConnectionVars; + + static Serializer get serializer => + _$gItemConnectionVarsSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GItemConnectionVars.serializer, + this, + ) as Map); + + static GItemConnectionVars? fromJson(Map json) => + _i1.serializers.deserializeWith( + GItemConnectionVars.serializer, + json, + ); +} + +abstract class GItemEdgeVars + implements Built { + GItemEdgeVars._(); + + factory GItemEdgeVars([void Function(GItemEdgeVarsBuilder b) updates]) = + _$GItemEdgeVars; + + static Serializer get serializer => _$gItemEdgeVarsSerializer; + + Map toJson() => (_i1.serializers.serializeWith( + GItemEdgeVars.serializer, + this, + ) as Map); + + static GItemEdgeVars? fromJson(Map json) => + _i1.serializers.deserializeWith( + GItemEdgeVars.serializer, + json, + ); +} diff --git a/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.var.gql.g.dart b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.var.gql.g.dart new file mode 100644 index 00000000..8a804da4 --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/__generated__/fragment_activities.var.gql.g.dart @@ -0,0 +1,414 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'fragment_activities.var.gql.dart'; + +// ************************************************************************** +// BuiltValueGenerator +// ************************************************************************** + +Serializer _$gActivityAVarsSerializer = + new _$GActivityAVarsSerializer(); +Serializer _$gActivityBVarsSerializer = + new _$GActivityBVarsSerializer(); +Serializer _$gItemVarsSerializer = new _$GItemVarsSerializer(); +Serializer _$gItemConnectionVarsSerializer = + new _$GItemConnectionVarsSerializer(); +Serializer _$gItemEdgeVarsSerializer = + new _$GItemEdgeVarsSerializer(); + +class _$GActivityAVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GActivityAVars, _$GActivityAVars]; + @override + final String wireName = 'GActivityAVars'; + + @override + Iterable serialize(Serializers serializers, GActivityAVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GActivityAVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GActivityAVarsBuilder().build(); + } +} + +class _$GActivityBVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [GActivityBVars, _$GActivityBVars]; + @override + final String wireName = 'GActivityBVars'; + + @override + Iterable serialize(Serializers serializers, GActivityBVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GActivityBVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GActivityBVarsBuilder().build(); + } +} + +class _$GItemVarsSerializer implements StructuredSerializer { + @override + final Iterable types = const [GItemVars, _$GItemVars]; + @override + final String wireName = 'GItemVars'; + + @override + Iterable serialize(Serializers serializers, GItemVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GItemVars deserialize(Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GItemVarsBuilder().build(); + } +} + +class _$GItemConnectionVarsSerializer + implements StructuredSerializer { + @override + final Iterable types = const [ + GItemConnectionVars, + _$GItemConnectionVars + ]; + @override + final String wireName = 'GItemConnectionVars'; + + @override + Iterable serialize( + Serializers serializers, GItemConnectionVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GItemConnectionVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GItemConnectionVarsBuilder().build(); + } +} + +class _$GItemEdgeVarsSerializer implements StructuredSerializer { + @override + final Iterable types = const [GItemEdgeVars, _$GItemEdgeVars]; + @override + final String wireName = 'GItemEdgeVars'; + + @override + Iterable serialize(Serializers serializers, GItemEdgeVars object, + {FullType specifiedType = FullType.unspecified}) { + return []; + } + + @override + GItemEdgeVars deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + return new GItemEdgeVarsBuilder().build(); + } +} + +class _$GActivityAVars extends GActivityAVars { + factory _$GActivityAVars([void Function(GActivityAVarsBuilder)? updates]) => + (new GActivityAVarsBuilder()..update(updates))._build(); + + _$GActivityAVars._() : super._(); + + @override + GActivityAVars rebuild(void Function(GActivityAVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GActivityAVarsBuilder toBuilder() => + new GActivityAVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GActivityAVars; + } + + @override + int get hashCode { + return 387328791; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GActivityAVars').toString(); + } +} + +class GActivityAVarsBuilder + implements Builder { + _$GActivityAVars? _$v; + + GActivityAVarsBuilder(); + + @override + void replace(GActivityAVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GActivityAVars; + } + + @override + void update(void Function(GActivityAVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GActivityAVars build() => _build(); + + _$GActivityAVars _build() { + final _$result = _$v ?? new _$GActivityAVars._(); + replace(_$result); + return _$result; + } +} + +class _$GActivityBVars extends GActivityBVars { + factory _$GActivityBVars([void Function(GActivityBVarsBuilder)? updates]) => + (new GActivityBVarsBuilder()..update(updates))._build(); + + _$GActivityBVars._() : super._(); + + @override + GActivityBVars rebuild(void Function(GActivityBVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GActivityBVarsBuilder toBuilder() => + new GActivityBVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GActivityBVars; + } + + @override + int get hashCode { + return 469057560; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GActivityBVars').toString(); + } +} + +class GActivityBVarsBuilder + implements Builder { + _$GActivityBVars? _$v; + + GActivityBVarsBuilder(); + + @override + void replace(GActivityBVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GActivityBVars; + } + + @override + void update(void Function(GActivityBVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GActivityBVars build() => _build(); + + _$GActivityBVars _build() { + final _$result = _$v ?? new _$GActivityBVars._(); + replace(_$result); + return _$result; + } +} + +class _$GItemVars extends GItemVars { + factory _$GItemVars([void Function(GItemVarsBuilder)? updates]) => + (new GItemVarsBuilder()..update(updates))._build(); + + _$GItemVars._() : super._(); + + @override + GItemVars rebuild(void Function(GItemVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GItemVarsBuilder toBuilder() => new GItemVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GItemVars; + } + + @override + int get hashCode { + return 1051824045; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GItemVars').toString(); + } +} + +class GItemVarsBuilder implements Builder { + _$GItemVars? _$v; + + GItemVarsBuilder(); + + @override + void replace(GItemVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GItemVars; + } + + @override + void update(void Function(GItemVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GItemVars build() => _build(); + + _$GItemVars _build() { + final _$result = _$v ?? new _$GItemVars._(); + replace(_$result); + return _$result; + } +} + +class _$GItemConnectionVars extends GItemConnectionVars { + factory _$GItemConnectionVars( + [void Function(GItemConnectionVarsBuilder)? updates]) => + (new GItemConnectionVarsBuilder()..update(updates))._build(); + + _$GItemConnectionVars._() : super._(); + + @override + GItemConnectionVars rebuild( + void Function(GItemConnectionVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GItemConnectionVarsBuilder toBuilder() => + new GItemConnectionVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GItemConnectionVars; + } + + @override + int get hashCode { + return 1013798405; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GItemConnectionVars').toString(); + } +} + +class GItemConnectionVarsBuilder + implements Builder { + _$GItemConnectionVars? _$v; + + GItemConnectionVarsBuilder(); + + @override + void replace(GItemConnectionVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GItemConnectionVars; + } + + @override + void update(void Function(GItemConnectionVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GItemConnectionVars build() => _build(); + + _$GItemConnectionVars _build() { + final _$result = _$v ?? new _$GItemConnectionVars._(); + replace(_$result); + return _$result; + } +} + +class _$GItemEdgeVars extends GItemEdgeVars { + factory _$GItemEdgeVars([void Function(GItemEdgeVarsBuilder)? updates]) => + (new GItemEdgeVarsBuilder()..update(updates))._build(); + + _$GItemEdgeVars._() : super._(); + + @override + GItemEdgeVars rebuild(void Function(GItemEdgeVarsBuilder) updates) => + (toBuilder()..update(updates)).build(); + + @override + GItemEdgeVarsBuilder toBuilder() => new GItemEdgeVarsBuilder()..replace(this); + + @override + bool operator ==(Object other) { + if (identical(other, this)) return true; + return other is GItemEdgeVars; + } + + @override + int get hashCode { + return 699140406; + } + + @override + String toString() { + return newBuiltValueToStringHelper(r'GItemEdgeVars').toString(); + } +} + +class GItemEdgeVarsBuilder + implements Builder { + _$GItemEdgeVars? _$v; + + GItemEdgeVarsBuilder(); + + @override + void replace(GItemEdgeVars other) { + ArgumentError.checkNotNull(other, 'other'); + _$v = other as _$GItemEdgeVars; + } + + @override + void update(void Function(GItemEdgeVarsBuilder)? updates) { + if (updates != null) updates(this); + } + + @override + GItemEdgeVars build() => _build(); + + _$GItemEdgeVars _build() { + final _$result = _$v ?? new _$GItemEdgeVars._(); + replace(_$result); + return _$result; + } +} + +// ignore_for_file: deprecated_member_use_from_same_package,type=lint diff --git a/codegen/end_to_end_test/lib/fragments/fragment_activities.graphql b/codegen/end_to_end_test/lib/fragments/fragment_activities.graphql new file mode 100644 index 00000000..722bcecf --- /dev/null +++ b/codegen/end_to_end_test/lib/fragments/fragment_activities.graphql @@ -0,0 +1,33 @@ +fragment ActivityA on ActivityA { + __typename + activityData { + __typename + } +} + +fragment ActivityB on ActivityB { + __typename + activity { + __typename + ... on ActivityA { + ...ActivityA + } + } +} + +fragment Item on Item { + __typename +} + + +fragment ItemConnection on ItemConnection { + __typename + count + edges { + ...ItemEdge + } +} + +fragment ItemEdge on ItemEdge { + __typename +} \ No newline at end of file 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 ce044936..087d8349 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 @@ -1169,6 +1169,163 @@ const Moderation = _i1.ObjectTypeDefinitionNode( ) ], ); +const ActivityA = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'ActivityA'), + directives: [], + interfaces: [], + fields: [ + _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: 'id'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ID'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'activityData'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ActivityUnion'), + isNonNull: false, + ), + ), + ], +); +const ActivityB = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'ActivityB'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'items'), + directives: [], + args: [ + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'after'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'String'), + isNonNull: false, + ), + defaultValue: null, + ), + _i1.InputValueDefinitionNode( + name: _i1.NameNode(value: 'first'), + directives: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: false, + ), + defaultValue: null, + ), + ], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ItemConnection'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'activity'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ActivityUnion'), + isNonNull: false, + ), + ), + ], +); +const ActivityUnion = _i1.UnionTypeDefinitionNode( + name: _i1.NameNode(value: 'ActivityUnion'), + directives: [], + types: [ + _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ActivityA'), + isNonNull: false, + ) + ], +); +const ItemConnection = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'ItemConnection'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'count'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: true, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'edges'), + directives: [], + args: [], + type: _i1.ListTypeNode( + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'ItemEdge'), + isNonNull: true, + ), + isNonNull: true, + ), + ), + ], +); +const ItemEdge = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'ItemEdge'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'cursor'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'String'), + isNonNull: false, + ), + ), + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'node'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Item'), + isNonNull: true, + ), + ), + ], +); +const Item = _i1.ObjectTypeDefinitionNode( + name: _i1.NameNode(value: 'Item'), + directives: [], + interfaces: [], + fields: [ + _i1.FieldDefinitionNode( + name: _i1.NameNode(value: 'count'), + directives: [], + args: [], + type: _i1.NamedTypeNode( + name: _i1.NameNode(value: 'Int'), + isNonNull: false, + ), + ) + ], +); const ModerationStatus = _i1.EnumTypeDefinitionNode( name: _i1.NameNode(value: 'ModerationStatus'), directives: [], @@ -1276,6 +1433,12 @@ const document = _i1.DocumentNode(definitions: [ User, Location, Moderation, + ActivityA, + ActivityB, + ActivityUnion, + ItemConnection, + ItemEdge, + Item, ModerationStatus, PostLikesInput, PostFavoritesInput, 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 f69ceb14..e3f4c0a6 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 @@ -215,6 +215,7 @@ const Map> possibleTypesMap = { 'Human', 'Droid', }, + 'ActivityUnion': {'ActivityA'}, 'SearchResult': { 'Human', 'Droid', 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 424dbcd3..c34fe4d9 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 @@ -24,6 +24,26 @@ import 'package:end_to_end_test/custom_field.dart'; import 'package:end_to_end_test/custom_field_serializer.dart' show CustomFieldSerializer; import 'package:end_to_end_test/date_serializer.dart' show DateSerializer; +import 'package:end_to_end_test/fragments/__generated__/fragment_activities.data.gql.dart' + show + GActivityBData_activity, + GActivityAData, + GActivityAData_activityData, + GActivityBData, + GActivityBData_activity__asActivityA, + GActivityBData_activity__asActivityA_activityData, + GActivityBData_activity__base, + GItemConnectionData, + GItemConnectionData_edges, + GItemData, + GItemEdgeData; +import 'package:end_to_end_test/fragments/__generated__/fragment_activities.var.gql.dart' + show + GActivityAVars, + GActivityBVars, + GItemConnectionVars, + GItemEdgeVars, + GItemVars; import 'package:end_to_end_test/fragments/__generated__/fragment_with_scalar_var.data.gql.dart' show GPostFragmentForUser1Data, @@ -158,12 +178,21 @@ final SerializersBuilder _serializersBuilder = _$serializers.toBuilder() ..add(OperationSerializer()) ..add(DateSerializer()) ..add(CustomFieldSerializer()) + ..add(GActivityBData_activity.serializer) ..add(GHeroForEpisodeData_hero.serializer) ..add(GheroFieldsFragmentData.serializer) ..add(GheroFieldsFragmentData__asHuman_friends.serializer) ..add(GhumanFieldsFragmentData_friends.serializer) ..addPlugin(StandardJsonPlugin()); @SerializersFor([ + GActivityAData, + GActivityAData_activityData, + GActivityAVars, + GActivityBData, + GActivityBData_activity__asActivityA, + GActivityBData_activity__asActivityA_activityData, + GActivityBData_activity__base, + GActivityBVars, GAliasedHero, GAliasedHeroData, GAliasedHeroData_empireHero, @@ -207,6 +236,13 @@ final SerializersBuilder _serializersBuilder = _$serializers.toBuilder() GHumanWithArgsData_human, GHumanWithArgsVars, GISODate, + GItemConnectionData, + GItemConnectionData_edges, + GItemConnectionVars, + GItemData, + GItemEdgeData, + GItemEdgeVars, + GItemVars, GJson, GLengthUnit, GModerationStatus, 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 18d1f7eb..3b3a63f9 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 @@ -7,6 +7,14 @@ part of 'serializers.gql.dart'; // ************************************************************************** Serializers _$serializers = (new Serializers().toBuilder() + ..add(GActivityAData.serializer) + ..add(GActivityAData_activityData.serializer) + ..add(GActivityAVars.serializer) + ..add(GActivityBData.serializer) + ..add(GActivityBData_activity__asActivityA.serializer) + ..add(GActivityBData_activity__asActivityA_activityData.serializer) + ..add(GActivityBData_activity__base.serializer) + ..add(GActivityBVars.serializer) ..add(GAliasedHero.serializer) ..add(GAliasedHeroData.serializer) ..add(GAliasedHeroData_empireHero.serializer) @@ -50,6 +58,13 @@ Serializers _$serializers = (new Serializers().toBuilder() ..add(GHumanWithArgsData_human.serializer) ..add(GHumanWithArgsVars.serializer) ..add(GISODate.serializer) + ..add(GItemConnectionData.serializer) + ..add(GItemConnectionData_edges.serializer) + ..add(GItemConnectionVars.serializer) + ..add(GItemData.serializer) + ..add(GItemEdgeData.serializer) + ..add(GItemEdgeVars.serializer) + ..add(GItemVars.serializer) ..add(GJson.serializer) ..add(GLengthUnit.serializer) ..add(GModerationStatus.serializer) @@ -113,6 +128,10 @@ Serializers _$serializers = (new Serializers().toBuilder() ..addBuilderFactory( const FullType(BuiltList, const [const FullType(CustomField)]), () => new ListBuilder()) + ..addBuilderFactory( + const FullType( + BuiltList, const [const FullType(GItemConnectionData_edges)]), + () => new ListBuilder()) ..addBuilderFactory( const FullType(BuiltList, const [const FullType.nullable(DateTime)]), () => new ListBuilder()) diff --git a/codegen/end_to_end_test/lib/graphql/schema.graphql b/codegen/end_to_end_test/lib/graphql/schema.graphql index b51a2919..8a954f3b 100644 --- a/codegen/end_to_end_test/lib/graphql/schema.graphql +++ b/codegen/end_to_end_test/lib/graphql/schema.graphql @@ -1,9 +1,9 @@ # Schema borrowed from https://github.com/apollographql/starwars-server schema { - query: Query - mutation: Mutation - subscription: Subscription + query: Query + mutation: Mutation + subscription: Subscription } directive @extends on OBJECT | INTERFACE @@ -11,220 +11,247 @@ 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] - currentUser: User + 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] + currentUser: User } # 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 + 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 + 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 + # 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]! + # 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 + # 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! + # 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 + # 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! + # 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 + # 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! + 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 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] + # 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 + id: ID! + customField: CustomField } # The input object sent when passing in a color input ColorInput { - red: Int! - green: Int! - blue: Int! + 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!]!] + # 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 + id: ID! + body: String! + favoritedUsers(where: PostLikesInput, filter: Json): PostLikes + likedUsers(where: PostFavoritesInput): PostFavorites } type PostLikes { - totalCount: Int! + totalCount: Int! } type PostFavorites { - totalCount: Int! + totalCount: Int! } type User { - id: ID! - location: Location - moderation: Moderation + id: ID! + location: Location + moderation: Moderation } type Location { - lat: Float! - lng: Float! + lat: Float! + lng: Float! } type Moderation { - moderationStatus: ModerationStatus! + moderationStatus: ModerationStatus! +} + +type ActivityA { + body: String! + id: ID! + activityData: ActivityUnion +} + +type ActivityB { + items(after: String, first: Int): ItemConnection! + activity: ActivityUnion +} + +union ActivityUnion = ActivityA + +type ItemConnection { + count: Int! + edges: [ItemEdge!]! +} + +type ItemEdge { + cursor: String + node: Item! +} + +type Item { + count: Int } enum ModerationStatus { - APPROVED - REJECTED - PENDING + APPROVED + REJECTED + PENDING } input PostLikesInput { - id: ID! + id: ID! } input PostFavoritesInput { - id: ID! + id: ID! } union SearchResult = Human | Droid | Starship diff --git a/codegen/end_to_end_test/test/operation/fragments_test.dart b/codegen/end_to_end_test/test/operation/fragments_test.dart index 82e74441..fe96557c 100644 --- a/codegen/end_to_end_test/test/operation/fragments_test.dart +++ b/codegen/end_to_end_test/test/operation/fragments_test.dart @@ -12,7 +12,7 @@ void main() { ..hero.name = "Leia" ..hero.friendsConnection.totalCount = 1 ..hero.friendsConnection.edges.add( - GHeroWithFragmentsData_hero_friendsConnection_edges( + GcomparisonFieldsData_friendsConnection_edges( (b) => b ..node.G__typename = "Human" ..node.name = "Luke", @@ -29,7 +29,7 @@ void main() { ..hero.name = "Leia" ..hero.friendsConnection.totalCount = 1 ..hero.friendsConnection.edges.add( - GHeroWithFragmentsData_hero_friendsConnection_edges( + GcomparisonFieldsData_friendsConnection_edges( (b) => b ..node.G__typename = "Human" ..node.name = "Luke", diff --git a/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart b/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart index 5ba924de..bd545475 100644 --- a/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart +++ b/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart @@ -36,8 +36,7 @@ List buildInlineFragmentClasses({ config: whenExtensionConfig, ); - List selectionsForInlineFragment( - InlineFragmentNode inlineFragment) { + List selectionsForInlineFragment(InlineFragmentNode inlineFragment) { final fragSelections = mergeSelections( [ ...selections.whereType(), @@ -50,22 +49,19 @@ List buildInlineFragmentClasses({ return fragSelections; } - Reference? existingFragmentWithSameSelections( - String typeName, List fragmentSelections) { + Reference? existingFragmentWithSameSelections(String typeName, List fragmentSelections) { final existing = fragmentRefMap[( typeName, BuiltSet.of( fragmentSelections.withoutFragmentSpreads, ) )]; - print( - "existing: $existing on $typeName with selections: $fragmentSelections"); + print("existing: $existing on $typeName with selections: $fragmentSelections"); return existing; } List buildSelectionSetClassesForInlineFragment( - InlineFragmentNode inlineFragment, - List fragmentSelections) => + InlineFragmentNode inlineFragment, List fragmentSelections) => buildSelectionSetDataClasses( name: _inlineFragmentName(name, inlineFragment), selections: fragmentSelections, @@ -87,8 +83,7 @@ List buildInlineFragmentClasses({ ...selections.whereType(), ], fragmentMap, true); - final existingFragment = - existingFragmentWithSameSelections(type, baseSelections); + final existingFragment = existingFragmentWithSameSelections(type, baseSelections); if (existingFragment != null) { final existingFragmentName = existingFragment.symbol; @@ -97,11 +92,17 @@ List buildInlineFragmentClasses({ print( "Found existing fragment $existingFragmentName with same selections as $targetName. Using $existingFragmentName instead."); print("adding typedef"); + /* TODO : make the fragmentData class a subtype of this class so we can use it here? + return [ + TypeDef((b) => b + ..name = targetName + ..definition = existingFragment), - return []; + + ]; + */ } else { - print( - "&&&&&&& no existing fragment found for $name on $type with selections: $baseSelections"); + print("&&&&&&& no existing fragment found for $name on $type with selections: $baseSelections"); } return [ @@ -112,9 +113,7 @@ List buildInlineFragmentClasses({ schemaSource: schemaSource, type: type, typeOverrides: typeOverrides, - superclassSelections: { - name: SourceSelections(url: null, selections: selections) - }, + superclassSelections: {name: SourceSelections(url: null, selections: selections)}, built: built, whenExtensionConfig: whenExtensionConfig, fragmentRefMap: fragmentRefMap, @@ -163,13 +162,11 @@ List buildInlineFragmentClasses({ ) .expand( (fragmentWithSelections) { - final (:inlineFragment, selections: fragmentSelections) = - fragmentWithSelections; + final (:inlineFragment, selections: fragmentSelections) = fragmentWithSelections; final typeName = inlineFragment.typeCondition!.on.name.value; - final existingFragment = - existingFragmentWithSameSelections(typeName, fragmentSelections); + final existingFragment = existingFragmentWithSameSelections(typeName, fragmentSelections); if (existingFragment != null) { final existingFragmentName = existingFragment.symbol; @@ -178,8 +175,10 @@ List buildInlineFragmentClasses({ print( "Found existing fragment $existingFragmentName with same selections as $targetName. Using $existingFragmentName instead."); print("adding typedef"); - + /* TODO : make the fragmentData class a subtype of this class so we can use it here? return []; + + */ } return buildSelectionSetClassesForInlineFragment( @@ -191,8 +190,7 @@ List buildInlineFragmentClasses({ ]; } -String _inlineFragmentName( - String baseName, InlineFragmentNode inlineFragment) => +String _inlineFragmentName(String baseName, InlineFragmentNode inlineFragment) => "${baseName}__as${inlineFragment.typeCondition!.on.name.value}"; String _inlineFragmentBaseName(String baseName) => "${baseName}__base"; @@ -205,8 +203,7 @@ List _inlineFragmentRootSerializationMethods({ final toJson = buildToJsonGetter(name); final fromJson = buildFromJsonGetter(name); - final inlineSerializer = - _inlineFragmentSerializer(name, inlineFragments, fragmentRefMap); + final inlineSerializer = _inlineFragmentSerializer(name, inlineFragments, fragmentRefMap); return [ inlineSerializer, @@ -226,8 +223,7 @@ Method _inlineFragmentSerializer( (b) => b ..body = TypeReference((b) => b ..symbol = "InlineFragmentSerializer" - ..url = - "package:gql_code_builder/src/serializers/inline_fragment_serializer.dart" + ..url = "package:gql_code_builder/src/serializers/inline_fragment_serializer.dart" ..types.add(refer(name))).call([ literalString(name), refer(_inlineFragmentBaseName(name)), @@ -235,8 +231,7 @@ Method _inlineFragmentSerializer( /// TODO: Handle inline fragments without a type condition /// https://spec.graphql.org/June2018/#sec-Inline-Fragments { - for (final v - in inlineFragments.where((frag) => frag.typeCondition != null)) + for (final v in inlineFragments.where((frag) => frag.typeCondition != null)) "${v.typeCondition!.on.name.value}": refer( _inlineFragmentName(name, v), ) From d7446e78b728027632e1f419334ff494c5def452 Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 7 Jan 2024 22:40:14 +0000 Subject: [PATCH 11/12] run codegen on the tristate repo --- .../alias_var_fragment.data.gql.dart | 106 +- .../alias_var_fragment.data.gql.g.dart | 564 +------ .../fragment_with_scalar_var.data.gql.dart | 78 +- .../fragment_with_scalar_var.data.gql.g.dart | 406 +---- .../hero_with_fragments.data.gql.dart | 212 +-- .../hero_with_fragments.data.gql.g.dart | 1300 ++--------------- ...interface_subtyped_fragments.data.gql.dart | 41 +- ...terface_subtyped_fragments.data.gql.g.dart | 236 +-- .../__generated__/serializers.gql.dart | 26 +- .../__generated__/serializers.gql.g.dart | 29 +- .../lib/src/inline_fragment_classes.dart | 40 +- 11 files changed, 205 insertions(+), 2833 deletions(-) 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 index 8aa047a2..3ed00df1 100644 --- 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 @@ -21,7 +21,7 @@ abstract class GPostsData implements Built { @BuiltValueField(wireName: '__typename') String get G__typename; - BuiltList? get posts; + BuiltList? get posts; static Serializer get serializer => _$gPostsDataSerializer; Map toJson() => (_i1.serializers.serializeWith( @@ -36,110 +36,6 @@ abstract class GPostsData implements Built { ); } -abstract class GPostsData_posts - implements Built, GPostFragment { - GPostsData_posts._(); - - factory GPostsData_posts([void 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( - [void 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( - [void 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; 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 index bdd60526..ef98fb84 100644 --- 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 @@ -7,13 +7,6 @@ part of 'alias_var_fragment.data.gql.dart'; // ************************************************************************** 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 @@ -42,8 +35,8 @@ class _$GPostsDataSerializer implements StructuredSerializer { result ..add('posts') ..add(serializers.serialize(value, - specifiedType: const FullType( - BuiltList, const [const FullType.nullable(GPostsData_posts)]))); + specifiedType: const FullType(BuiltList, + const [const FullType.nullable(GPostFragmentData)]))); } return result; } @@ -66,7 +59,7 @@ class _$GPostsDataSerializer implements StructuredSerializer { case 'posts': result.posts.replace(serializers.deserialize(value, specifiedType: const FullType(BuiltList, const [ - const FullType.nullable(GPostsData_posts) + const FullType.nullable(GPostFragmentData) ]))! as BuiltList); break; } @@ -76,184 +69,6 @@ class _$GPostsDataSerializer implements StructuredSerializer { } } -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 @@ -436,7 +251,7 @@ class _$GPostsData extends GPostsData { @override final String G__typename; @override - final BuiltList? posts; + final BuiltList? posts; factory _$GPostsData([void Function(GPostsDataBuilder)? updates]) => (new GPostsDataBuilder()..update(updates))._build(); @@ -486,10 +301,10 @@ class GPostsDataBuilder implements Builder { 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; + ListBuilder? _posts; + ListBuilder get posts => + _$this._posts ??= new ListBuilder(); + set posts(ListBuilder? posts) => _$this._posts = posts; GPostsDataBuilder() { GPostsData._initializeBuilder(this); @@ -543,369 +358,6 @@ class GPostsDataBuilder implements Builder { } } -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; 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 index e73ca323..25c52743 100644 --- 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 @@ -24,7 +24,7 @@ abstract class GPostsWithFixedVariableData @BuiltValueField(wireName: '__typename') String get G__typename; - BuiltList? get posts; + BuiltList? get posts; static Serializer get serializer => _$gPostsWithFixedVariableDataSerializer; @@ -40,82 +40,6 @@ abstract class GPostsWithFixedVariableData ); } -abstract class GPostsWithFixedVariableData_posts - implements - Built, - GPostFragmentForUser1 { - GPostsWithFixedVariableData_posts._(); - - factory GPostsWithFixedVariableData_posts( - [void 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( - [void 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; 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 index e5559c99..17ad831c 100644 --- 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 @@ -9,12 +9,6 @@ part of 'fragment_with_scalar_var.data.gql.dart'; Serializer _$gPostsWithFixedVariableDataSerializer = new _$GPostsWithFixedVariableDataSerializer(); -Serializer - _$gPostsWithFixedVariableDataPostsSerializer = - new _$GPostsWithFixedVariableData_postsSerializer(); -Serializer - _$gPostsWithFixedVariableDataPostsFavoritedUsersSerializer = - new _$GPostsWithFixedVariableData_posts_favoritedUsersSerializer(); Serializer _$gPostFragmentForUser1DataSerializer = new _$GPostFragmentForUser1DataSerializer(); Serializer @@ -46,9 +40,8 @@ class _$GPostsWithFixedVariableDataSerializer result ..add('posts') ..add(serializers.serialize(value, - specifiedType: const FullType(BuiltList, const [ - const FullType.nullable(GPostsWithFixedVariableData_posts) - ]))); + specifiedType: const FullType(BuiltList, + const [const FullType.nullable(GPostFragmentForUser1Data)]))); } return result; } @@ -72,7 +65,7 @@ class _$GPostsWithFixedVariableDataSerializer case 'posts': result.posts.replace(serializers.deserialize(value, specifiedType: const FullType(BuiltList, const [ - const FullType.nullable(GPostsWithFixedVariableData_posts) + const FullType.nullable(GPostFragmentForUser1Data) ]))! as BuiltList); break; } @@ -82,127 +75,6 @@ class _$GPostsWithFixedVariableDataSerializer } } -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 @@ -326,7 +198,7 @@ class _$GPostsWithFixedVariableData extends GPostsWithFixedVariableData { @override final String G__typename; @override - final BuiltList? posts; + final BuiltList? posts; factory _$GPostsWithFixedVariableData( [void Function(GPostsWithFixedVariableDataBuilder)? updates]) => @@ -383,10 +255,10 @@ class GPostsWithFixedVariableDataBuilder 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) => + ListBuilder? _posts; + ListBuilder get posts => + _$this._posts ??= new ListBuilder(); + set posts(ListBuilder? posts) => _$this._posts = posts; GPostsWithFixedVariableDataBuilder() { @@ -441,268 +313,6 @@ class GPostsWithFixedVariableDataBuilder } } -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; 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 index 0e518fa5..2082f25b 100644 --- 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 @@ -23,7 +23,7 @@ abstract class GHeroWithFragmentsData @BuiltValueField(wireName: '__typename') String get G__typename; - GHeroWithFragmentsData_hero? get hero; + GcomparisonFieldsData? get hero; static Serializer get serializer => _$gHeroWithFragmentsDataSerializer; @@ -39,162 +39,6 @@ abstract class GHeroWithFragmentsData ); } -abstract class GHeroWithFragmentsData_hero - implements - Built, - GcomparisonFields { - GHeroWithFragmentsData_hero._(); - - factory GHeroWithFragmentsData_hero( - [void 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( - [void 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( - [void 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( - [void 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; @@ -251,17 +95,7 @@ abstract class GcomparisonFields_friendsConnection { 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 + GheroDataData? get node; Map toJson(); } @@ -362,7 +196,7 @@ abstract class GcomparisonFieldsData_friendsConnection_edges @BuiltValueField(wireName: '__typename') String get G__typename; @override - GcomparisonFieldsData_friendsConnection_edges_node? get node; + GheroDataData? get node; static Serializer get serializer => _$gcomparisonFieldsDataFriendsConnectionEdgesSerializer; @@ -379,43 +213,3 @@ abstract class GcomparisonFieldsData_friendsConnection_edges json, ); } - -abstract class GcomparisonFieldsData_friendsConnection_edges_node - implements - Built, - GcomparisonFields_friendsConnection_edges_node, - GheroData { - GcomparisonFieldsData_friendsConnection_edges_node._(); - - factory GcomparisonFieldsData_friendsConnection_edges_node( - [void 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 index b5005f79..f0764d9c 100644 --- 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 @@ -8,17 +8,6 @@ part of 'hero_with_fragments.data.gql.dart'; 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 = @@ -29,9 +18,6 @@ Serializer Serializer _$gcomparisonFieldsDataFriendsConnectionEdgesSerializer = new _$GcomparisonFieldsData_friendsConnection_edgesSerializer(); -Serializer - _$gcomparisonFieldsDataFriendsConnectionEdgesNodeSerializer = - new _$GcomparisonFieldsData_friendsConnection_edges_nodeSerializer(); class _$GHeroWithFragmentsDataSerializer implements StructuredSerializer { @@ -58,7 +44,7 @@ class _$GHeroWithFragmentsDataSerializer result ..add('hero') ..add(serializers.serialize(value, - specifiedType: const FullType(GHeroWithFragmentsData_hero))); + specifiedType: const FullType(GcomparisonFieldsData))); } return result; } @@ -81,269 +67,8 @@ class _$GHeroWithFragmentsDataSerializer 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; + specifiedType: const FullType(GcomparisonFieldsData))! + as GcomparisonFieldsData); break; } } @@ -501,841 +226,214 @@ class _$GcomparisonFieldsData_friendsConnectionSerializer 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); + ]))); + } + return result; } - GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder get _$this { - final $v = _$v; - if ($v != null) { - _G__typename = $v.G__typename; - _node = $v.node?.toBuilder(); - _$v = null; + @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 this; + + return result.build(); } +} +class _$GcomparisonFieldsData_friendsConnection_edgesSerializer + implements + StructuredSerializer { @override - void replace(GHeroWithFragmentsData_hero_friendsConnection_edges other) { - ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$GHeroWithFragmentsData_hero_friendsConnection_edges; - } + final Iterable types = const [ + GcomparisonFieldsData_friendsConnection_edges, + _$GcomparisonFieldsData_friendsConnection_edges + ]; + @override + final String wireName = 'GcomparisonFieldsData_friendsConnection_edges'; @override - void update( - void Function(GHeroWithFragmentsData_hero_friendsConnection_edgesBuilder)? - updates) { - if (updates != null) updates(this); + 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(GheroDataData))); + } + return result; } @override - GHeroWithFragmentsData_hero_friendsConnection_edges build() => _build(); + GcomparisonFieldsData_friendsConnection_edges deserialize( + Serializers serializers, Iterable serialized, + {FullType specifiedType = FullType.unspecified}) { + final result = new GcomparisonFieldsData_friendsConnection_edgesBuilder(); - _$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()); + 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(GheroDataData))! as GheroDataData); + break; } - rethrow; } - replace(_$result); - return _$result; + + return result.build(); } } -class _$GHeroWithFragmentsData_hero_friendsConnection_edges_node - extends GHeroWithFragmentsData_hero_friendsConnection_edges_node { +class _$GHeroWithFragmentsData extends GHeroWithFragmentsData { @override final String G__typename; @override - final String name; + final GcomparisonFieldsData? hero; - factory _$GHeroWithFragmentsData_hero_friendsConnection_edges_node( - [void Function( - GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder)? - updates]) => - (new GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder() - ..update(updates)) - ._build(); + factory _$GHeroWithFragmentsData( + [void Function(GHeroWithFragmentsDataBuilder)? updates]) => + (new GHeroWithFragmentsDataBuilder()..update(updates))._build(); - _$GHeroWithFragmentsData_hero_friendsConnection_edges_node._( - {required this.G__typename, required this.name}) + _$GHeroWithFragmentsData._({required this.G__typename, this.hero}) : super._() { BuiltValueNullFieldError.checkNotNull( - G__typename, - r'GHeroWithFragmentsData_hero_friendsConnection_edges_node', - 'G__typename'); - BuiltValueNullFieldError.checkNotNull(name, - r'GHeroWithFragmentsData_hero_friendsConnection_edges_node', 'name'); + G__typename, r'GHeroWithFragmentsData', 'G__typename'); } @override - GHeroWithFragmentsData_hero_friendsConnection_edges_node rebuild( - void Function( - GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder) - updates) => + GHeroWithFragmentsData rebuild( + void Function(GHeroWithFragmentsDataBuilder) updates) => (toBuilder()..update(updates)).build(); @override - GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder toBuilder() => - new GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder() - ..replace(this); + GHeroWithFragmentsDataBuilder toBuilder() => + new GHeroWithFragmentsDataBuilder()..replace(this); @override bool operator ==(Object other) { if (identical(other, this)) return true; - return other is GHeroWithFragmentsData_hero_friendsConnection_edges_node && + return other is GHeroWithFragmentsData && G__typename == other.G__typename && - name == other.name; + hero == other.hero; } @override int get hashCode { var _$hash = 0; _$hash = $jc(_$hash, G__typename.hashCode); - _$hash = $jc(_$hash, name.hashCode); + _$hash = $jc(_$hash, hero.hashCode); _$hash = $jf(_$hash); return _$hash; } @override String toString() { - return (newBuiltValueToStringHelper( - r'GHeroWithFragmentsData_hero_friendsConnection_edges_node') + return (newBuiltValueToStringHelper(r'GHeroWithFragmentsData') ..add('G__typename', G__typename) - ..add('name', name)) + ..add('hero', hero)) .toString(); } } -class GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder - implements - Builder { - _$GHeroWithFragmentsData_hero_friendsConnection_edges_node? _$v; +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; - String? _name; - String? get name => _$this._name; - set name(String? name) => _$this._name = name; + GcomparisonFieldsDataBuilder? _hero; + GcomparisonFieldsDataBuilder get hero => + _$this._hero ??= new GcomparisonFieldsDataBuilder(); + set hero(GcomparisonFieldsDataBuilder? hero) => _$this._hero = hero; - GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder() { - GHeroWithFragmentsData_hero_friendsConnection_edges_node._initializeBuilder( - this); + GHeroWithFragmentsDataBuilder() { + GHeroWithFragmentsData._initializeBuilder(this); } - GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder get _$this { + GHeroWithFragmentsDataBuilder get _$this { final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; - _name = $v.name; + _hero = $v.hero?.toBuilder(); _$v = null; } return this; } @override - void replace(GHeroWithFragmentsData_hero_friendsConnection_edges_node other) { + void replace(GHeroWithFragmentsData other) { ArgumentError.checkNotNull(other, 'other'); - _$v = other as _$GHeroWithFragmentsData_hero_friendsConnection_edges_node; + _$v = other as _$GHeroWithFragmentsData; } @override - void update( - void Function( - GHeroWithFragmentsData_hero_friendsConnection_edges_nodeBuilder)? - updates) { + void update(void Function(GHeroWithFragmentsDataBuilder)? updates) { if (updates != null) updates(this); } @override - GHeroWithFragmentsData_hero_friendsConnection_edges_node build() => _build(); + GHeroWithFragmentsData 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')); + _$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; } @@ -1740,7 +838,7 @@ class _$GcomparisonFieldsData_friendsConnection_edges @override final String G__typename; @override - final GcomparisonFieldsData_friendsConnection_edges_node? node; + final GheroDataData? node; factory _$GcomparisonFieldsData_friendsConnection_edges( [void Function(GcomparisonFieldsData_friendsConnection_edgesBuilder)? @@ -1803,12 +901,9 @@ class GcomparisonFieldsData_friendsConnection_edgesBuilder 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; + GheroDataDataBuilder? _node; + GheroDataDataBuilder get node => _$this._node ??= new GheroDataDataBuilder(); + set node(GheroDataDataBuilder? node) => _$this._node = node; GcomparisonFieldsData_friendsConnection_edgesBuilder() { GcomparisonFieldsData_friendsConnection_edges._initializeBuilder(this); @@ -1868,125 +963,4 @@ class GcomparisonFieldsData_friendsConnection_edgesBuilder } } -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_interface_subtyped_fragments.data.gql.dart b/codegen/end_to_end_test_tristate/lib/fragments/__generated__/hero_with_interface_subtyped_fragments.data.gql.dart index 556761b7..02d1bb7d 100644 --- 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 @@ -28,7 +28,7 @@ abstract class GHeroWithInterfaceSubTypedFragmentsData @BuiltValueField(wireName: '__typename') String get G__typename; - GHeroWithInterfaceSubTypedFragmentsData_hero? get hero; + GheroFieldsFragmentData? get hero; static Serializer get serializer => _$gHeroWithInterfaceSubTypedFragmentsDataSerializer; @@ -45,45 +45,6 @@ abstract class GHeroWithInterfaceSubTypedFragmentsData ); } -abstract class GHeroWithInterfaceSubTypedFragmentsData_hero - implements - Built, - GheroFieldsFragment { - GHeroWithInterfaceSubTypedFragmentsData_hero._(); - - factory GHeroWithInterfaceSubTypedFragmentsData_hero( - [void 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; 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 index 20c08793..4f772a52 100644 --- 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 @@ -9,9 +9,6 @@ part of 'hero_with_interface_subtyped_fragments.data.gql.dart'; Serializer _$gHeroWithInterfaceSubTypedFragmentsDataSerializer = new _$GHeroWithInterfaceSubTypedFragmentsDataSerializer(); -Serializer - _$gHeroWithInterfaceSubTypedFragmentsDataHeroSerializer = - new _$GHeroWithInterfaceSubTypedFragmentsData_heroSerializer(); Serializer _$gheroFieldsFragmentDataBaseSerializer = new _$GheroFieldsFragmentData__baseSerializer(); @@ -69,8 +66,7 @@ class _$GHeroWithInterfaceSubTypedFragmentsDataSerializer result ..add('hero') ..add(serializers.serialize(value, - specifiedType: - const FullType(GHeroWithInterfaceSubTypedFragmentsData_hero))); + specifiedType: const FullType(GheroFieldsFragmentData))); } return result; } @@ -92,69 +88,9 @@ class _$GHeroWithInterfaceSubTypedFragmentsDataSerializer 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; + result.hero = serializers.deserialize(value, + specifiedType: const FullType(GheroFieldsFragmentData)) + as GheroFieldsFragmentData?; break; } } @@ -884,7 +820,7 @@ class _$GHeroWithInterfaceSubTypedFragmentsData @override final String G__typename; @override - final GHeroWithInterfaceSubTypedFragmentsData_hero? hero; + final GheroFieldsFragmentData? hero; factory _$GHeroWithInterfaceSubTypedFragmentsData( [void Function(GHeroWithInterfaceSubTypedFragmentsDataBuilder)? @@ -946,12 +882,9 @@ class GHeroWithInterfaceSubTypedFragmentsDataBuilder 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; + GheroFieldsFragmentData? _hero; + GheroFieldsFragmentData? get hero => _$this._hero; + set hero(GheroFieldsFragmentData? hero) => _$this._hero = hero; GHeroWithInterfaceSubTypedFragmentsDataBuilder() { GHeroWithInterfaceSubTypedFragmentsData._initializeBuilder(this); @@ -961,7 +894,7 @@ class GHeroWithInterfaceSubTypedFragmentsDataBuilder final $v = _$v; if ($v != null) { _G__typename = $v.G__typename; - _hero = $v.hero?.toBuilder(); + _hero = $v.hero; _$v = null; } return this; @@ -983,156 +916,11 @@ class GHeroWithInterfaceSubTypedFragmentsDataBuilder 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._( + new _$GHeroWithInterfaceSubTypedFragmentsData._( 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')); + r'GHeroWithInterfaceSubTypedFragmentsData', 'G__typename'), + hero: hero); replace(_$result); return _$result; } 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 index 15090df8..a975a2c4 100644 --- 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 @@ -6,10 +6,7 @@ import 'package:end_to_end_test_tristate/aliases/__generated__/alias_var_fragmen GPostFragmentData, GPostFragmentData_isFavorited, GPostFragmentData_isLiked, - GPostsData, - GPostsData_posts, - GPostsData_posts_isFavorited, - GPostsData_posts_isLiked; + GPostsData; 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' @@ -32,9 +29,7 @@ import 'package:end_to_end_test_tristate/fragments/__generated__/fragment_with_s show GPostFragmentForUser1Data, GPostFragmentForUser1Data_favoritedUsers, - GPostsWithFixedVariableData, - GPostsWithFixedVariableData_posts, - GPostsWithFixedVariableData_posts_favoritedUsers; + GPostsWithFixedVariableData; 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' @@ -42,14 +37,9 @@ import 'package:end_to_end_test_tristate/fragments/__generated__/fragment_with_s 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; @@ -61,7 +51,6 @@ import 'package:end_to_end_test_tristate/fragments/__generated__/hero_with_inter GheroFieldsFragmentData__asHuman_friends, GhumanFieldsFragmentData_friends, GHeroWithInterfaceSubTypedFragmentsData, - GHeroWithInterfaceSubTypedFragmentsData_hero, GdroidFieldsFragmentData, GheroFieldsFragmentData__asDroid, GheroFieldsFragmentData__asHuman, @@ -194,14 +183,9 @@ final SerializersBuilder _serializersBuilder = _$serializers.toBuilder() 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, @@ -221,14 +205,9 @@ final SerializersBuilder _serializersBuilder = _$serializers.toBuilder() GPostLikesInput, GPosts, GPostsData, - GPostsData_posts, - GPostsData_posts_isFavorited, - GPostsData_posts_isLiked, GPostsVars, GPostsWithFixedVariable, GPostsWithFixedVariableData, - GPostsWithFixedVariableData_posts, - GPostsWithFixedVariableData_posts_favoritedUsers, GPostsWithFixedVariableVars, GReviewInput, GReviewWithDate, @@ -238,7 +217,6 @@ final SerializersBuilder _serializersBuilder = _$serializers.toBuilder() GcomparisonFieldsData, GcomparisonFieldsData_friendsConnection, GcomparisonFieldsData_friendsConnection_edges, - GcomparisonFieldsData_friendsConnection_edges_node, GcomparisonFieldsVars, GdroidFieldsFragmentData, GdroidFieldsFragmentVars, 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 index 86cbb01f..915e6729 100644 --- 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 @@ -41,14 +41,9 @@ Serializers _$serializers = (new Serializers().toBuilder() ..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) @@ -68,14 +63,9 @@ Serializers _$serializers = (new Serializers().toBuilder() ..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) @@ -85,7 +75,6 @@ Serializers _$serializers = (new Serializers().toBuilder() ..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) @@ -129,22 +118,14 @@ Serializers _$serializers = (new Serializers().toBuilder() 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()) + BuiltList, const [const FullType.nullable(GPostFragmentData)]), + () => new ListBuilder()) ..addBuilderFactory( - const FullType(BuiltList, const [ - const FullType.nullable(GPostsWithFixedVariableData_posts) - ]), - () => new ListBuilder()) + const FullType(BuiltList, + const [const FullType.nullable(GPostFragmentForUser1Data)]), + () => new ListBuilder()) ..addBuilderFactory( const FullType(BuiltList, const [ const FullType.nullable( diff --git a/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart b/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart index bd545475..85453999 100644 --- a/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart +++ b/codegen/gql_code_builder/lib/src/inline_fragment_classes.dart @@ -36,7 +36,8 @@ List buildInlineFragmentClasses({ config: whenExtensionConfig, ); - List selectionsForInlineFragment(InlineFragmentNode inlineFragment) { + List selectionsForInlineFragment( + InlineFragmentNode inlineFragment) { final fragSelections = mergeSelections( [ ...selections.whereType(), @@ -49,19 +50,22 @@ List buildInlineFragmentClasses({ return fragSelections; } - Reference? existingFragmentWithSameSelections(String typeName, List fragmentSelections) { + Reference? existingFragmentWithSameSelections( + String typeName, List fragmentSelections) { final existing = fragmentRefMap[( typeName, BuiltSet.of( fragmentSelections.withoutFragmentSpreads, ) )]; - print("existing: $existing on $typeName with selections: $fragmentSelections"); + print( + "existing: $existing on $typeName with selections: $fragmentSelections"); return existing; } List buildSelectionSetClassesForInlineFragment( - InlineFragmentNode inlineFragment, List fragmentSelections) => + InlineFragmentNode inlineFragment, + List fragmentSelections) => buildSelectionSetDataClasses( name: _inlineFragmentName(name, inlineFragment), selections: fragmentSelections, @@ -83,7 +87,8 @@ List buildInlineFragmentClasses({ ...selections.whereType(), ], fragmentMap, true); - final existingFragment = existingFragmentWithSameSelections(type, baseSelections); + final existingFragment = + existingFragmentWithSameSelections(type, baseSelections); if (existingFragment != null) { final existingFragmentName = existingFragment.symbol; @@ -102,7 +107,8 @@ List buildInlineFragmentClasses({ ]; */ } else { - print("&&&&&&& no existing fragment found for $name on $type with selections: $baseSelections"); + print( + "&&&&&&& no existing fragment found for $name on $type with selections: $baseSelections"); } return [ @@ -113,7 +119,9 @@ List buildInlineFragmentClasses({ schemaSource: schemaSource, type: type, typeOverrides: typeOverrides, - superclassSelections: {name: SourceSelections(url: null, selections: selections)}, + superclassSelections: { + name: SourceSelections(url: null, selections: selections) + }, built: built, whenExtensionConfig: whenExtensionConfig, fragmentRefMap: fragmentRefMap, @@ -162,11 +170,13 @@ List buildInlineFragmentClasses({ ) .expand( (fragmentWithSelections) { - final (:inlineFragment, selections: fragmentSelections) = fragmentWithSelections; + final (:inlineFragment, selections: fragmentSelections) = + fragmentWithSelections; final typeName = inlineFragment.typeCondition!.on.name.value; - final existingFragment = existingFragmentWithSameSelections(typeName, fragmentSelections); + final existingFragment = + existingFragmentWithSameSelections(typeName, fragmentSelections); if (existingFragment != null) { final existingFragmentName = existingFragment.symbol; @@ -190,7 +200,8 @@ List buildInlineFragmentClasses({ ]; } -String _inlineFragmentName(String baseName, InlineFragmentNode inlineFragment) => +String _inlineFragmentName( + String baseName, InlineFragmentNode inlineFragment) => "${baseName}__as${inlineFragment.typeCondition!.on.name.value}"; String _inlineFragmentBaseName(String baseName) => "${baseName}__base"; @@ -203,7 +214,8 @@ List _inlineFragmentRootSerializationMethods({ final toJson = buildToJsonGetter(name); final fromJson = buildFromJsonGetter(name); - final inlineSerializer = _inlineFragmentSerializer(name, inlineFragments, fragmentRefMap); + final inlineSerializer = + _inlineFragmentSerializer(name, inlineFragments, fragmentRefMap); return [ inlineSerializer, @@ -223,7 +235,8 @@ Method _inlineFragmentSerializer( (b) => b ..body = TypeReference((b) => b ..symbol = "InlineFragmentSerializer" - ..url = "package:gql_code_builder/src/serializers/inline_fragment_serializer.dart" + ..url = + "package:gql_code_builder/src/serializers/inline_fragment_serializer.dart" ..types.add(refer(name))).call([ literalString(name), refer(_inlineFragmentBaseName(name)), @@ -231,7 +244,8 @@ Method _inlineFragmentSerializer( /// TODO: Handle inline fragments without a type condition /// https://spec.graphql.org/June2018/#sec-Inline-Fragments { - for (final v in inlineFragments.where((frag) => frag.typeCondition != null)) + for (final v + in inlineFragments.where((frag) => frag.typeCondition != null)) "${v.typeCondition!.on.name.value}": refer( _inlineFragmentName(name, v), ) From 214c5e59c451a1b9bd625e2c110eef4bcaae7e7a Mon Sep 17 00:00:00 2001 From: Martin Kamleithner Date: Sun, 7 Jan 2024 22:43:25 +0000 Subject: [PATCH 12/12] run codegen on the tristate repo --- .../test/operation/fragments_test.dart | 4 ++-- codegen/gql_code_builder/lib/src/operation/data.dart | 6 +----- 2 files changed, 3 insertions(+), 7 deletions(-) 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 index 36b68915..dbf32496 100644 --- a/codegen/end_to_end_test_tristate/test/operation/fragments_test.dart +++ b/codegen/end_to_end_test_tristate/test/operation/fragments_test.dart @@ -12,7 +12,7 @@ void main() { ..hero.name = "Leia" ..hero.friendsConnection.totalCount = 1 ..hero.friendsConnection.edges.add( - GHeroWithFragmentsData_hero_friendsConnection_edges( + GcomparisonFieldsData_friendsConnection_edges( (b) => b ..node.G__typename = "Human" ..node.name = "Luke", @@ -29,7 +29,7 @@ void main() { ..hero.name = "Leia" ..hero.friendsConnection.totalCount = 1 ..hero.friendsConnection.edges.add( - GHeroWithFragmentsData_hero_friendsConnection_edges( + GcomparisonFieldsData_friendsConnection_edges( (b) => b ..node.G__typename = "Human" ..node.name = "Luke", diff --git a/codegen/gql_code_builder/lib/src/operation/data.dart b/codegen/gql_code_builder/lib/src/operation/data.dart index 6cb902d7..8a6a3f66 100644 --- a/codegen/gql_code_builder/lib/src/operation/data.dart +++ b/codegen/gql_code_builder/lib/src/operation/data.dart @@ -1,9 +1,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/data.dart"; -import "package:gql_code_builder/src/config/when_extension_config.dart"; import "../../source.dart"; import "../built_class.dart"; @@ -68,7 +66,7 @@ List buildFragmentDataClasses( fragmentRefMap[(fragmentType, set)] = refer( builtClassName("${frag.name.value}Data"), - (docSource.url ?? "") + "#data", + (docSource.url) + "#data", ); //TODO /*for (final possibleType in possibleTypesMap[fragmentType] ?? {}) { @@ -174,8 +172,6 @@ List buildSelectionSetDataClasses({ ); } - final canonicalSelections = BuiltSet.of(selections.withoutFragmentSpreads); - final superclassSelectionNodes = superclassSelections.values .expand((selections) => selections.selections) .toSet();