From 6ccf28daec4a4e4ee2bdca10a3b1065ef96ae486 Mon Sep 17 00:00:00 2001 From: Christian Budde Christensen Date: Wed, 22 Feb 2023 11:08:51 +0000 Subject: [PATCH] feat: Add typename default to constructor --- packages/graphql_codegen/CHANGELOG.md | 4 ++++ .../example/lib/fragments.graphql.dart | 4 ++-- .../example/lib/main.graphql.dart | 14 ++++++------- .../lib/src/printer/base/document.dart | 17 +++++++++++----- packages/graphql_codegen/pubspec.yaml | 2 +- .../assets/add_typenames/schema.graphql.dart | 16 +++++++-------- .../condition_example/fragments.graphql.dart | 16 +++++++-------- .../condition_example/query.graphql.dart | 2 +- .../assets/copy_with/document.graphql.dart | 8 ++++---- .../custom_enums/document_2.graphql.dart | 2 +- .../test/assets/extends/document.graphql.dart | 4 ++-- .../fragment_and_field/document.graphql.dart | 6 +++--- .../schema.graphql.dart | 8 ++++---- .../fragment_variables/document.graphql.dart | 16 +++++++-------- .../fragment_variables_2/schema.graphql.dart | 4 ++-- .../document.graphql.dart | 4 ++-- .../assets/gql_extensions/document.gql.dart | 2 +- .../document.graphql.dart | 2 +- .../document2.graphql.dart | 2 +- .../schema.graphql.dart | 12 +++++------ .../document.graphql.dart | 2 +- .../document.graphql.dart | 2 +- .../query.graphql.dart | 12 +++++------ .../document.graphql.dart | 20 +++++++++---------- .../assets/issue_158/document.graphql.dart | 6 +++--- .../test/assets/issue_168/schema.graphql.dart | 10 +++++----- .../assets/issue_184/document.graphql.dart | 2 +- .../assets/issue_192/document.graphql.dart | 4 ++-- .../assets/issue_206/document.graphql.dart | 14 ++++++------- .../generated/schemaA/document.graphql.dart | 2 +- .../generated/schemaB/document.graphql.dart | 2 +- .../assets/issue_239/document.graphql.dart | 6 +++--- .../json_converters/document.graphql.dart | 2 +- .../lots_of_fragments/document.graphql.dart | 8 ++++---- .../multiple_interfaces/document.graphql.dart | 2 +- .../naming_config/document.graphql.dart | 2 +- .../document.graphql.dart | 10 +++++----- .../__generated/folder/document.graphql.dart | 2 +- .../f2/__generated__/document.graphql.dart | 2 +- .../document.graphql.dart | 4 ++-- .../fragments/document.graphql.dart | 2 +- .../queries/document.graphql.dart | 2 +- .../fragments/document.graphql.dart | 2 +- .../queries/document.graphql.dart | 2 +- .../test/assets/scopes/a.query.graphql.dart | 4 ++-- .../test/assets/scopes/b.query.graphql.dart | 4 ++-- .../test/assets/unions/document.graphql.dart | 4 ++-- 47 files changed, 145 insertions(+), 134 deletions(-) diff --git a/packages/graphql_codegen/CHANGELOG.md b/packages/graphql_codegen/CHANGELOG.md index 613ee48f..871268f6 100644 --- a/packages/graphql_codegen/CHANGELOG.md +++ b/packages/graphql_codegen/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.12.0-beta.10 + +* Provide default typename parameter to constructor + # 0.12.0-beta.9 * Support schema extensions. diff --git a/packages/graphql_codegen/example/lib/fragments.graphql.dart b/packages/graphql_codegen/example/lib/fragments.graphql.dart index b96fa238..5ac9a50e 100644 --- a/packages/graphql_codegen/example/lib/fragments.graphql.dart +++ b/packages/graphql_codegen/example/lib/fragments.graphql.dart @@ -11,7 +11,7 @@ class Fragment$PersonSummary { this.eventsOfEvents, this.parents, this.favParent, - required this.$__typename, + this.$__typename = 'Person', }); factory Fragment$PersonSummary.fromJson(Map json) { @@ -470,7 +470,7 @@ extension ClientExtension$Fragment$PersonSummary on graphql.GraphQLClient { class Fragment$PersonParent { Fragment$PersonParent({ required this.name, - required this.$__typename, + this.$__typename = 'Person', }); factory Fragment$PersonParent.fromJson(Map json) { diff --git a/packages/graphql_codegen/example/lib/main.graphql.dart b/packages/graphql_codegen/example/lib/main.graphql.dart index 0959fafc..31e9ab93 100644 --- a/packages/graphql_codegen/example/lib/main.graphql.dart +++ b/packages/graphql_codegen/example/lib/main.graphql.dart @@ -103,7 +103,7 @@ class _CopyWithStubImpl$Variables$Query$FetchPerson class Query$FetchPerson { Query$FetchPerson({ this.fetchPerson, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$FetchPerson.fromJson(Map json) { @@ -461,7 +461,7 @@ class Query$FetchPerson$fetchPerson implements Fragment$PersonSummary { this.eventsOfEvents, this.parents, this.favParent, - required this.$__typename, + this.$__typename = 'Person', this.children, }); @@ -846,7 +846,7 @@ class Query$FetchPerson$fetchPerson$parents implements Fragment$PersonParent, Fragment$PersonSummary { Query$FetchPerson$fetchPerson$parents({ required this.name, - required this.$__typename, + this.$__typename = 'Person', this.nickname, this.dob, this.events, @@ -1278,7 +1278,7 @@ class _CopyWithStubImpl$Variables$Mutation$UpdatePerson class Mutation$UpdatePerson { Mutation$UpdatePerson({ this.updatePerson, - required this.$__typename, + this.$__typename = 'Mutation', }); factory Mutation$UpdatePerson.fromJson(Map json) { @@ -1669,7 +1669,7 @@ class Mutation$UpdatePerson$Widget class Mutation$UpdatePerson$updatePerson { Mutation$UpdatePerson$updatePerson({ required this.full_name, - required this.$__typename, + this.$__typename = 'Person', }); factory Mutation$UpdatePerson$updatePerson.fromJson( @@ -1900,7 +1900,7 @@ class _CopyWithStubImpl$Variables$Subscription$WatchPerson class Subscription$WatchPerson { Subscription$WatchPerson({ this.watchPerson, - required this.$__typename, + this.$__typename = 'Subscription', }); factory Subscription$WatchPerson.fromJson(Map json) { @@ -2193,7 +2193,7 @@ class Subscription$WatchPerson$Widget class Subscription$WatchPerson$watchPerson { Subscription$WatchPerson$watchPerson({ required this.full_name, - required this.$__typename, + this.$__typename = 'Person', }); factory Subscription$WatchPerson$watchPerson.fromJson( diff --git a/packages/graphql_codegen/lib/src/printer/base/document.dart b/packages/graphql_codegen/lib/src/printer/base/document.dart index 5ca156ff..0fc56932 100644 --- a/packages/graphql_codegen/lib/src/printer/base/document.dart +++ b/packages/graphql_codegen/lib/src/printer/base/document.dart @@ -76,11 +76,18 @@ Constructor _printConstructor( [ ...properties.map( (p) => Parameter( - (b) => b - ..required = p.isRequired - ..named = true - ..toThis = true - ..name = c.namePrinter.printPropertyName(p.name), + (b) { + final defaultTo = p.isTypenameField && + c.context.currentType is ObjectTypeDefinitionNode + ? literalString(c.context.currentTypeName.value).code + : null; + b + ..required = p.isRequired && defaultTo == null + ..named = true + ..toThis = true + ..defaultTo = defaultTo + ..name = c.namePrinter.printPropertyName(p.name); + }, ), ), ], diff --git a/packages/graphql_codegen/pubspec.yaml b/packages/graphql_codegen/pubspec.yaml index ef6497cb..7ed31b49 100644 --- a/packages/graphql_codegen/pubspec.yaml +++ b/packages/graphql_codegen/pubspec.yaml @@ -3,7 +3,7 @@ description: | Simple, opinionated, codegen library for GraphQL. It allows you to generate serializers and client helpers to easily call and parse your data. -version: 0.12.0-beta.9 +version: 0.12.0-beta.10 homepage: https://github.com/heftapp/graphql_codegen/tree/main/packages/graphql_codegen repository: https://github.com/heftapp/graphql_codegen/tree/main/packages/graphql_codegen diff --git a/packages/graphql_codegen/test/assets/add_typenames/schema.graphql.dart b/packages/graphql_codegen/test/assets/add_typenames/schema.graphql.dart index cd2fcc17..e3d4edbc 100644 --- a/packages/graphql_codegen/test/assets/add_typenames/schema.graphql.dart +++ b/packages/graphql_codegen/test/assets/add_typenames/schema.graphql.dart @@ -3,7 +3,7 @@ import 'package:gql/ast.dart'; class Fragment$FReport { Fragment$FReport({ this.title, - required this.$__typename, + this.$__typename = 'Report', }); factory Fragment$FReport.fromJson(Map json) { @@ -156,7 +156,7 @@ class Query$Q { this.docsWihtoutTypename, this.docsWithAliasedTypename, this.docsWithFragment, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { @@ -705,7 +705,7 @@ class _CopyWithStubImpl$Query$Q$docsWithTypename } class Query$Q$docsWithTypename$$Contract implements Query$Q$docsWithTypename { - Query$Q$docsWithTypename$$Contract({required this.$__typename}); + Query$Q$docsWithTypename$$Contract({this.$__typename = 'Contract'}); factory Query$Q$docsWithTypename$$Contract.fromJson( Map json) { @@ -799,7 +799,7 @@ class _CopyWithStubImpl$Query$Q$docsWithTypename$$Contract } class Query$Q$docsWithTypename$$Report implements Query$Q$docsWithTypename { - Query$Q$docsWithTypename$$Report({required this.$__typename}); + Query$Q$docsWithTypename$$Report({this.$__typename = 'Report'}); factory Query$Q$docsWithTypename$$Report.fromJson(Map json) { final l$$__typename = json['__typename']; @@ -1026,7 +1026,7 @@ class Query$Q$docsWihtoutTypename$$Contract implements Query$Q$docsWihtoutTypename { Query$Q$docsWihtoutTypename$$Contract({ this.title, - required this.$__typename, + this.$__typename = 'Contract', }); factory Query$Q$docsWihtoutTypename$$Contract.fromJson( @@ -1152,7 +1152,7 @@ class Query$Q$docsWihtoutTypename$$Report implements Query$Q$docsWihtoutTypename { Query$Q$docsWihtoutTypename$$Report({ this.title, - required this.$__typename, + this.$__typename = 'Report', }); factory Query$Q$docsWihtoutTypename$$Report.fromJson( @@ -1659,7 +1659,7 @@ class _CopyWithStubImpl$Query$Q$docsWithFragment class Query$Q$docsWithFragment$$Contract implements Query$Q$docsWithFragment { Query$Q$docsWithFragment$$Contract({ this.title, - required this.$__typename, + this.$__typename = 'Contract', }); factory Query$Q$docsWithFragment$$Contract.fromJson( @@ -1785,7 +1785,7 @@ class Query$Q$docsWithFragment$$Report implements Fragment$FReport, Query$Q$docsWithFragment { Query$Q$docsWithFragment$$Report({ this.title, - required this.$__typename, + this.$__typename = 'Report', }); factory Query$Q$docsWithFragment$$Report.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/condition_example/fragments.graphql.dart b/packages/graphql_codegen/test/assets/condition_example/fragments.graphql.dart index 019aae9c..29144032 100644 --- a/packages/graphql_codegen/test/assets/condition_example/fragments.graphql.dart +++ b/packages/graphql_codegen/test/assets/condition_example/fragments.graphql.dart @@ -164,7 +164,7 @@ const documentNodeFragmentCondition = DocumentNode(definitions: [ class Fragment$Condition$$AndCondition implements Fragment$Condition { Fragment$Condition$$AndCondition({ required this.name, - required this.$__typename, + this.$__typename = 'AndCondition', }); factory Fragment$Condition$$AndCondition.fromJson(Map json) { @@ -289,7 +289,7 @@ class _CopyWithStubImpl$Fragment$Condition$$AndCondition class Fragment$Condition$$TimeCondition implements Fragment$Condition { Fragment$Condition$$TimeCondition({ required this.name, - required this.$__typename, + this.$__typename = 'TimeCondition', }); factory Fragment$Condition$$TimeCondition.fromJson( @@ -417,7 +417,7 @@ class Fragment$AndCondition implements Fragment$Condition$$AndCondition { required this.left, required this.right, required this.name, - required this.$__typename, + this.$__typename = 'AndCondition', }); factory Fragment$AndCondition.fromJson(Map json) { @@ -842,7 +842,7 @@ class Fragment$CompositeCondition$$AndCondition required this.left, required this.right, required this.name, - required this.$__typename, + this.$__typename = 'AndCondition', }); factory Fragment$CompositeCondition$$AndCondition.fromJson( @@ -1030,7 +1030,7 @@ class Fragment$CompositeCondition$$TimeCondition Fragment$CompositeCondition { Fragment$CompositeCondition$$TimeCondition({ required this.name, - required this.$__typename, + this.$__typename = 'TimeCondition', required this.before, }); @@ -1346,7 +1346,7 @@ class Fragment$NonCompositeCondition$$AndCondition Fragment$NonCompositeCondition { Fragment$NonCompositeCondition$$AndCondition({ required this.name, - required this.$__typename, + this.$__typename = 'AndCondition', }); factory Fragment$NonCompositeCondition$$AndCondition.fromJson( @@ -1477,7 +1477,7 @@ class Fragment$NonCompositeCondition$$TimeCondition Fragment$NonCompositeCondition { Fragment$NonCompositeCondition$$TimeCondition({ required this.name, - required this.$__typename, + this.$__typename = 'TimeCondition', required this.before, }); @@ -1625,7 +1625,7 @@ class _CopyWithStubImpl$Fragment$NonCompositeCondition$$TimeCondition class Fragment$TimeCondition implements Fragment$Condition$$TimeCondition { Fragment$TimeCondition({ required this.name, - required this.$__typename, + this.$__typename = 'TimeCondition', required this.before, }); diff --git a/packages/graphql_codegen/test/assets/condition_example/query.graphql.dart b/packages/graphql_codegen/test/assets/condition_example/query.graphql.dart index b03bbf26..82b8d341 100644 --- a/packages/graphql_codegen/test/assets/condition_example/query.graphql.dart +++ b/packages/graphql_codegen/test/assets/condition_example/query.graphql.dart @@ -4,7 +4,7 @@ import 'package:gql/ast.dart'; class Query$FetchShouldRender { Query$FetchShouldRender({ required this.shouldRender, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$FetchShouldRender.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/copy_with/document.graphql.dart b/packages/graphql_codegen/test/assets/copy_with/document.graphql.dart index a7eb55b3..20995964 100644 --- a/packages/graphql_codegen/test/assets/copy_with/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/copy_with/document.graphql.dart @@ -4,7 +4,7 @@ class Query$Foobar { Query$Foobar({ this.ts, this.tss, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Foobar.fromJson(Map json) { @@ -307,7 +307,7 @@ class Query$Foobar$ts { Query$Foobar$ts({ this.t, this.name, - required this.$__typename, + this.$__typename = 'TS', }); factory Query$Foobar$ts.fromJson(Map json) { @@ -456,7 +456,7 @@ class _CopyWithStubImpl$Query$Foobar$ts class Query$Foobar$ts$t { Query$Foobar$ts$t({ this.name, - required this.$__typename, + this.$__typename = 'TS', }); factory Query$Foobar$ts$t.fromJson(Map json) { @@ -577,7 +577,7 @@ class _CopyWithStubImpl$Query$Foobar$ts$t class Query$Foobar$tss { Query$Foobar$tss({ required this.nameEnforced, - required this.$__typename, + this.$__typename = 'TS', }); factory Query$Foobar$tss.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/custom_enums/document_2.graphql.dart b/packages/graphql_codegen/test/assets/custom_enums/document_2.graphql.dart index c84391ea..923c2d98 100644 --- a/packages/graphql_codegen/test/assets/custom_enums/document_2.graphql.dart +++ b/packages/graphql_codegen/test/assets/custom_enums/document_2.graphql.dart @@ -4,7 +4,7 @@ import 'package:gql/ast.dart'; class Query$Q { Query$Q({ this.value, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/extends/document.graphql.dart b/packages/graphql_codegen/test/assets/extends/document.graphql.dart index 95475e29..f35e7cca 100644 --- a/packages/graphql_codegen/test/assets/extends/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/extends/document.graphql.dart @@ -162,7 +162,7 @@ class Query$Q { this.string, this.$int, this.i, - required this.$__typename, + this.$__typename = 'Q', }); factory Query$Q.fromJson(Map json) { @@ -492,7 +492,7 @@ class _CopyWithStubImpl$Query$Q$i implements CopyWith$Query$Q$i { class Mutation$M { Mutation$M({ this.string, - required this.$__typename, + this.$__typename = 'M', }); factory Mutation$M.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/fragment_and_field/document.graphql.dart b/packages/graphql_codegen/test/assets/fragment_and_field/document.graphql.dart index 31977741..b74fee76 100644 --- a/packages/graphql_codegen/test/assets/fragment_and_field/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/fragment_and_field/document.graphql.dart @@ -3,7 +3,7 @@ import 'package:gql/ast.dart'; class Fragment$FPerson { Fragment$FPerson({ this.age, - required this.$__typename, + this.$__typename = 'Person', }); factory Fragment$FPerson.fromJson(Map json) { @@ -153,7 +153,7 @@ const documentNodeFragmentFPerson = DocumentNode(definitions: [ class Query$Q { Query$Q({ this.person, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { @@ -456,7 +456,7 @@ class Query$Q$person$$Person implements Fragment$FPerson, Query$Q$person { Query$Q$person$$Person({ this.name, this.age, - required this.$__typename, + this.$__typename = 'Person', }); factory Query$Q$person$$Person.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/fragment_enum_variables/schema.graphql.dart b/packages/graphql_codegen/test/assets/fragment_enum_variables/schema.graphql.dart index 3716e202..d5a30616 100644 --- a/packages/graphql_codegen/test/assets/fragment_enum_variables/schema.graphql.dart +++ b/packages/graphql_codegen/test/assets/fragment_enum_variables/schema.graphql.dart @@ -216,7 +216,7 @@ class _CopyWithStubImpl$Variables$Fragment$F1 class Fragment$F1 implements Fragment$F2 { Fragment$F1({ this.n2, - required this.$__typename, + this.$__typename = 'Node', this.n1, }); @@ -485,7 +485,7 @@ class _CopyWithStubImpl$Variables$Fragment$F2 class Fragment$F2 { Fragment$F2({ this.n2, - required this.$__typename, + this.$__typename = 'Node', }); factory Fragment$F2.fromJson(Map json) { @@ -736,7 +736,7 @@ class _CopyWithStubImpl$Variables$Fragment$F3 class Fragment$F3 { Fragment$F3({ this.test, - required this.$__typename, + this.$__typename = 'Node', }); factory Fragment$F3.fromJson(Map json) { @@ -983,7 +983,7 @@ class Fragment$F4 { Fragment$F4({ this.n1, this.n2, - required this.$__typename, + this.$__typename = 'Node', }); factory Fragment$F4.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/fragment_variables/document.graphql.dart b/packages/graphql_codegen/test/assets/fragment_variables/document.graphql.dart index 3f0ccfad..cb4a210b 100644 --- a/packages/graphql_codegen/test/assets/fragment_variables/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/fragment_variables/document.graphql.dart @@ -231,7 +231,7 @@ class _CopyWithStubImpl$Variables$Fragment$F1 class Fragment$F1 { Fragment$F1({ this.level1, - required this.$__typename, + this.$__typename = 'Query', }); factory Fragment$F1.fromJson(Map json) { @@ -456,7 +456,7 @@ const documentNodeFragmentF1 = DocumentNode(definitions: [ class Fragment$F1$level1 { Fragment$F1$level1({ this.level2, - required this.$__typename, + this.$__typename = 'Level1', }); factory Fragment$F1$level1.fromJson(Map json) { @@ -592,7 +592,7 @@ class _CopyWithStubImpl$Fragment$F1$level1 class Fragment$F1$level1$level2 { Fragment$F1$level1$level2({ this.level3, - required this.$__typename, + this.$__typename = 'Level2', }); factory Fragment$F1$level1$level2.fromJson(Map json) { @@ -730,7 +730,7 @@ class _CopyWithStubImpl$Fragment$F1$level1$level2 class Fragment$F1$level1$level2$level3 { Fragment$F1$level1$level2$level3({ this.level4, - required this.$__typename, + this.$__typename = 'Level3', }); factory Fragment$F1$level1$level2$level3.fromJson(Map json) { @@ -990,7 +990,7 @@ class _CopyWithStubImpl$Variables$Fragment$F2 class Fragment$F2 { Fragment$F2({ this.level1, - required this.$__typename, + this.$__typename = 'Query', }); factory Fragment$F2.fromJson(Map json) { @@ -1266,7 +1266,7 @@ class _CopyWithStubImpl$Variables$Fragment$F21 class Fragment$F21 { Fragment$F21({ this.level2, - required this.$__typename, + this.$__typename = 'Level1', }); factory Fragment$F21.fromJson(Map json) { @@ -1474,7 +1474,7 @@ const documentNodeFragmentF21 = DocumentNode(definitions: [ class Fragment$F21$level2 { Fragment$F21$level2({ this.level3, - required this.$__typename, + this.$__typename = 'Level2', }); factory Fragment$F21$level2.fromJson(Map json) { @@ -1610,7 +1610,7 @@ class _CopyWithStubImpl$Fragment$F21$level2 class Fragment$F21$level2$level3 { Fragment$F21$level2$level3({ this.level4, - required this.$__typename, + this.$__typename = 'Level3', }); factory Fragment$F21$level2$level3.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/fragment_variables_2/schema.graphql.dart b/packages/graphql_codegen/test/assets/fragment_variables_2/schema.graphql.dart index 4ce5524c..9f10847c 100644 --- a/packages/graphql_codegen/test/assets/fragment_variables_2/schema.graphql.dart +++ b/packages/graphql_codegen/test/assets/fragment_variables_2/schema.graphql.dart @@ -100,7 +100,7 @@ class _CopyWithStubImpl$Variables$Fragment$NameNode class Fragment$NameNode { Fragment$NameNode({ this.name, - required this.$__typename, + this.$__typename = 'Node', }); factory Fragment$NameNode.fromJson(Map json) { @@ -387,7 +387,7 @@ class _CopyWithStubImpl$Variables$Query$Q class Query$Q { Query$Q({ this.node, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/fragments_and_loose_type_requirements/document.graphql.dart b/packages/graphql_codegen/test/assets/fragments_and_loose_type_requirements/document.graphql.dart index 2517382a..a10a80a7 100644 --- a/packages/graphql_codegen/test/assets/fragments_and_loose_type_requirements/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/fragments_and_loose_type_requirements/document.graphql.dart @@ -186,7 +186,7 @@ const documentNodeFragmentF = DocumentNode(definitions: [ class Fragment$F$$T implements Fragment$F { Fragment$F$$T({ - required this.$__typename, + this.$__typename = 'T', this.t, this.name, }); @@ -544,7 +544,7 @@ const documentNodeQueryQ = DocumentNode(definitions: [ class Query$Q$t implements Fragment$F$$T { Query$Q$t({ - required this.$__typename, + this.$__typename = 'T', this.name, this.t, }); diff --git a/packages/graphql_codegen/test/assets/gql_extensions/document.gql.dart b/packages/graphql_codegen/test/assets/gql_extensions/document.gql.dart index 47195102..565f42fc 100644 --- a/packages/graphql_codegen/test/assets/gql_extensions/document.gql.dart +++ b/packages/graphql_codegen/test/assets/gql_extensions/document.gql.dart @@ -3,7 +3,7 @@ import 'package:gql/ast.dart'; class Query$FetchCount { Query$FetchCount({ this.fetchCount, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$FetchCount.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/graphql_client_nested_fragments/document.graphql.dart b/packages/graphql_codegen/test/assets/graphql_client_nested_fragments/document.graphql.dart index f8cf5acd..aac4911e 100644 --- a/packages/graphql_codegen/test/assets/graphql_client_nested_fragments/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/graphql_client_nested_fragments/document.graphql.dart @@ -6,7 +6,7 @@ class Fragment$F1 { Fragment$F1({ this.name, this.field, - required this.$__typename, + this.$__typename = 'T1', }); factory Fragment$F1.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/graphql_client_nested_fragments/document2.graphql.dart b/packages/graphql_codegen/test/assets/graphql_client_nested_fragments/document2.graphql.dart index 7047e746..7b515840 100644 --- a/packages/graphql_codegen/test/assets/graphql_client_nested_fragments/document2.graphql.dart +++ b/packages/graphql_codegen/test/assets/graphql_client_nested_fragments/document2.graphql.dart @@ -4,7 +4,7 @@ import 'package:graphql/client.dart' as graphql; class Fragment$F2 { Fragment$F2({ this.name, - required this.$__typename, + this.$__typename = 'T1', }); factory Fragment$F2.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/graphql_flutter_client_subscription/schema.graphql.dart b/packages/graphql_codegen/test/assets/graphql_flutter_client_subscription/schema.graphql.dart index 4e622f28..8a3c8ef9 100644 --- a/packages/graphql_codegen/test/assets/graphql_flutter_client_subscription/schema.graphql.dart +++ b/packages/graphql_codegen/test/assets/graphql_flutter_client_subscription/schema.graphql.dart @@ -7,7 +7,7 @@ import 'package:graphql_flutter/graphql_flutter.dart' as graphql_flutter; class Subscription$NoArgs { Subscription$NoArgs({ this.listenForChange, - required this.$__typename, + this.$__typename = 'Subscription', }); factory Subscription$NoArgs.fromJson(Map json) { @@ -273,7 +273,7 @@ class Subscription$NoArgs$Widget class Subscription$NoArgs$listenForChange { Subscription$NoArgs$listenForChange({ required this.name, - required this.$__typename, + this.$__typename = 'Change', }); factory Subscription$NoArgs$listenForChange.fromJson( @@ -497,7 +497,7 @@ class _CopyWithStubImpl$Variables$Subscription$RequiredArg class Subscription$RequiredArg { Subscription$RequiredArg({ this.listenForChange, - required this.$__typename, + this.$__typename = 'Subscription', }); factory Subscription$RequiredArg.fromJson(Map json) { @@ -791,7 +791,7 @@ class Subscription$RequiredArg$Widget class Subscription$RequiredArg$listenForChange { Subscription$RequiredArg$listenForChange({ required this.name, - required this.$__typename, + this.$__typename = 'Change', }); factory Subscription$RequiredArg$listenForChange.fromJson( @@ -1022,7 +1022,7 @@ class _CopyWithStubImpl$Variables$Subscription$OptionalArg class Subscription$OptionalArg { Subscription$OptionalArg({ this.listenForChange, - required this.$__typename, + this.$__typename = 'Subscription', }); factory Subscription$OptionalArg.fromJson(Map json) { @@ -1316,7 +1316,7 @@ class Subscription$OptionalArg$Widget class Subscription$OptionalArg$listenForChange { Subscription$OptionalArg$listenForChange({ required this.name, - required this.$__typename, + this.$__typename = 'Change', }); factory Subscription$OptionalArg$listenForChange.fromJson( diff --git a/packages/graphql_codegen/test/assets/graphql_flutter_naming_config/document.graphql.dart b/packages/graphql_codegen/test/assets/graphql_flutter_naming_config/document.graphql.dart index 4f11b4d4..d07608c8 100644 --- a/packages/graphql_codegen/test/assets/graphql_flutter_naming_config/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/graphql_flutter_naming_config/document.graphql.dart @@ -140,7 +140,7 @@ Enum___Status fromJson___Enum___Status(String value) { class Query___Q { Query___Q({ this.status, - required this.$__typename, + this.$__typename = 'Query', }); factory Query___Q.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/include_if_null_input/document.graphql.dart b/packages/graphql_codegen/test/assets/include_if_null_input/document.graphql.dart index cd598b8c..fe266af1 100644 --- a/packages/graphql_codegen/test/assets/include_if_null_input/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/include_if_null_input/document.graphql.dart @@ -246,7 +246,7 @@ class _CopyWithStubImpl$Variables$Query$Q1 class Query$Q1 { Query$Q1({ this.field, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q1.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/interface_and_fragments/query.graphql.dart b/packages/graphql_codegen/test/assets/interface_and_fragments/query.graphql.dart index 9f33df43..785e35e3 100644 --- a/packages/graphql_codegen/test/assets/interface_and_fragments/query.graphql.dart +++ b/packages/graphql_codegen/test/assets/interface_and_fragments/query.graphql.dart @@ -727,7 +727,7 @@ class _CopyWithStubImpl$Query$FetchImplementations$interface$self class Query$FetchImplementations$interface$self$$ImplementationA implements Fragment$FragmentA, Query$FetchImplementations$interface$self { Query$FetchImplementations$interface$self$$ImplementationA({ - required this.$__typename, + this.$__typename = 'ImplementationA', this.s, this.$_s, }); @@ -884,7 +884,7 @@ class _CopyWithStubImpl$Query$FetchImplementations$interface$self$$Implementatio class Query$FetchImplementations$interface$self$$ImplementationB implements Fragment$FragmentB, Query$FetchImplementations$interface$self { Query$FetchImplementations$interface$self$$ImplementationB({ - required this.$__typename, + this.$__typename = 'ImplementationB', this.i, }); @@ -1026,7 +1026,7 @@ class Query$FetchImplementations$interface$$ImplementationA this.b, this.s, this.$_s, - required this.typename, + this.typename = 'ImplementationA', required this.self, }); @@ -1228,7 +1228,7 @@ class Query$FetchImplementations$interface$$ImplementationB implements Fragment$FragmentB, Query$FetchImplementations$interface { Query$FetchImplementations$interface$$ImplementationB({ this.i, - required this.typename, + this.typename = 'ImplementationB', this.b, required this.self, }); @@ -1413,7 +1413,7 @@ class _CopyWithStubImpl$Query$FetchImplementations$interface$$ImplementationB< class Query$FetchImplementations$interface$$ImplementationA$self implements Fragment$FragmentA, Query$FetchImplementations$interface$self { Query$FetchImplementations$interface$$ImplementationA$self({ - required this.$__typename, + this.$__typename = 'ImplementationA', this.s, this.$_s, }); @@ -1570,7 +1570,7 @@ class _CopyWithStubImpl$Query$FetchImplementations$interface$$ImplementationA$se class Query$FetchImplementations$interface$$ImplementationB$self implements Fragment$FragmentB, Query$FetchImplementations$interface$self { Query$FetchImplementations$interface$$ImplementationB$self({ - required this.$__typename, + this.$__typename = 'ImplementationB', this.i, }); diff --git a/packages/graphql_codegen/test/assets/interfaces_and_concrete_types/document.graphql.dart b/packages/graphql_codegen/test/assets/interfaces_and_concrete_types/document.graphql.dart index e4c5192c..69fa289b 100644 --- a/packages/graphql_codegen/test/assets/interfaces_and_concrete_types/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/interfaces_and_concrete_types/document.graphql.dart @@ -3,7 +3,7 @@ import 'package:gql/ast.dart'; class Query$FetchI { Query$FetchI({ this.i1, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$FetchI.fromJson(Map json) { @@ -739,7 +739,7 @@ class _CopyWithStubImpl$Query$FetchI$i1$i2$field class Query$FetchI$i1$i2$field$$TField implements Query$FetchI$i1$i2$field { Query$FetchI$i1$i2$field$$TField({ this.name, - required this.$__typename, + this.$__typename = 'TField', }); factory Query$FetchI$i1$i2$field$$TField.fromJson(Map json) { @@ -862,7 +862,7 @@ class _CopyWithStubImpl$Query$FetchI$i1$i2$field$$TField class Query$FetchI$i1$i2$$T2 implements Query$FetchI$i1$i2 { Query$FetchI$i1$i2$$T2({ this.field, - required this.$__typename, + this.$__typename = 'T2', }); factory Query$FetchI$i1$i2$$T2.fromJson(Map json) { @@ -999,7 +999,7 @@ class _CopyWithStubImpl$Query$FetchI$i1$i2$$T2 class Query$FetchI$i1$i2$$T2$field implements Query$FetchI$i1$i2$field { Query$FetchI$i1$i2$$T2$field({ this.name, - required this.$__typename, + this.$__typename = 'TField', }); factory Query$FetchI$i1$i2$$T2$field.fromJson(Map json) { @@ -1123,7 +1123,7 @@ class Query$FetchI$i1$$T1 implements Query$FetchI$i1 { Query$FetchI$i1$$T1({ this.i2c, this.i2, - required this.$__typename, + this.$__typename = 'T1', }); factory Query$FetchI$i1$$T1.fromJson(Map json) { @@ -1286,7 +1286,7 @@ class _CopyWithStubImpl$Query$FetchI$i1$$T1 class Query$FetchI$i1$$T1$i2c { Query$FetchI$i1$$T1$i2c({ this.field, - required this.$__typename, + this.$__typename = 'T2', }); factory Query$FetchI$i1$$T1$i2c.fromJson(Map json) { @@ -1423,7 +1423,7 @@ class _CopyWithStubImpl$Query$FetchI$i1$$T1$i2c class Query$FetchI$i1$$T1$i2c$field { Query$FetchI$i1$$T1$i2c$field({ this.age, - required this.$__typename, + this.$__typename = 'TField', }); factory Query$FetchI$i1$$T1$i2c$field.fromJson(Map json) { @@ -1819,7 +1819,7 @@ class Query$FetchI$i1$$T1$i2$field$$TField implements Query$FetchI$i1$$T1$i2$field { Query$FetchI$i1$$T1$i2$field$$TField({ this.name, - required this.$__typename, + this.$__typename = 'TField', }); factory Query$FetchI$i1$$T1$i2$field$$TField.fromJson( @@ -1944,7 +1944,7 @@ class _CopyWithStubImpl$Query$FetchI$i1$$T1$i2$field$$TField class Query$FetchI$i1$$T1$i2$$T2 implements Query$FetchI$i1$$T1$i2 { Query$FetchI$i1$$T1$i2$$T2({ this.field, - required this.$__typename, + this.$__typename = 'T2', }); factory Query$FetchI$i1$$T1$i2$$T2.fromJson(Map json) { @@ -2082,7 +2082,7 @@ class _CopyWithStubImpl$Query$FetchI$i1$$T1$i2$$T2 class Query$FetchI$i1$$T1$i2$$T2$field implements Query$FetchI$i1$$T1$i2$field { Query$FetchI$i1$$T1$i2$$T2$field({ this.age, - required this.$__typename, + this.$__typename = 'TField', this.name, }); diff --git a/packages/graphql_codegen/test/assets/issue_158/document.graphql.dart b/packages/graphql_codegen/test/assets/issue_158/document.graphql.dart index 35d6bb0a..4b954a23 100644 --- a/packages/graphql_codegen/test/assets/issue_158/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/issue_158/document.graphql.dart @@ -160,7 +160,7 @@ const documentNodeFragmentPersonSummary = DocumentNode(definitions: [ class Fragment$PersonSummary$$Person implements Fragment$PersonSummary { Fragment$PersonSummary$$Person({ required this.id, - required this.$__typename, + this.$__typename = 'Person', }); factory Fragment$PersonSummary$$Person.fromJson(Map json) { @@ -283,7 +283,7 @@ class _CopyWithStubImpl$Fragment$PersonSummary$$Person class Query$GetPerson { Query$GetPerson({ this.person, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$GetPerson.fromJson(Map json) { @@ -460,7 +460,7 @@ const documentNodeQueryGetPerson = DocumentNode(definitions: [ class Query$GetPerson$person implements Fragment$PersonSummary$$Person { Query$GetPerson$person({ required this.id, - required this.$__typename, + this.$__typename = 'Person', }); factory Query$GetPerson$person.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/issue_168/schema.graphql.dart b/packages/graphql_codegen/test/assets/issue_168/schema.graphql.dart index 1854842b..1308aac8 100644 --- a/packages/graphql_codegen/test/assets/issue_168/schema.graphql.dart +++ b/packages/graphql_codegen/test/assets/issue_168/schema.graphql.dart @@ -211,7 +211,7 @@ class _CopyWithStubImpl$Variables$Query$WalletGetContent class Query$WalletGetContent { Query$WalletGetContent({ required this.walletGetContent, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$WalletGetContent.fromJson(Map json) { @@ -522,7 +522,7 @@ const documentNodeQueryWalletGetContent = DocumentNode(definitions: [ class Query$WalletGetContent$walletGetContent { Query$WalletGetContent$walletGetContent({ this.blocks, - required this.$__typename, + this.$__typename = 'WalletGetContentPayload', }); factory Query$WalletGetContent$walletGetContent.fromJson( @@ -788,7 +788,7 @@ class Query$WalletGetContent$walletGetContent$blocks$$WalletContentBlockList required this.blockType, this.caption, this.items, - required this.$__typename, + this.$__typename = 'WalletContentBlockList', }); factory Query$WalletGetContent$walletGetContent$blocks$$WalletContentBlockList.fromJson( @@ -1046,7 +1046,7 @@ class _CopyWithStubImpl$Query$WalletGetContent$walletGetContent$blocks$$WalletCo class Query$WalletGetContent$walletGetContent$blocks$$WalletContentBlockList$blockType { Query$WalletGetContent$walletGetContent$blocks$$WalletContentBlockList$blockType({ required this.id, - required this.$__typename, + this.$__typename = 'WalletContentBlockType', }); factory Query$WalletGetContent$walletGetContent$blocks$$WalletContentBlockList$blockType.fromJson( @@ -1313,7 +1313,7 @@ class Query$WalletGetContent$walletGetContent$blocks$$WalletContentBlockList$ite this.caption, this.imageURL, this.link, - required this.$__typename, + this.$__typename = 'WalletContentItemContentPreview', }); factory Query$WalletGetContent$walletGetContent$blocks$$WalletContentBlockList$items$$WalletContentItemContentPreview.fromJson( diff --git a/packages/graphql_codegen/test/assets/issue_184/document.graphql.dart b/packages/graphql_codegen/test/assets/issue_184/document.graphql.dart index 3e1ba08e..1fdbabe5 100644 --- a/packages/graphql_codegen/test/assets/issue_184/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/issue_184/document.graphql.dart @@ -3,7 +3,7 @@ import 'package:gql/ast.dart'; class Fragment$F { Fragment$F({ this.$default, - required this.$__typename, + this.$__typename = 'Person', }); factory Fragment$F.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/issue_192/document.graphql.dart b/packages/graphql_codegen/test/assets/issue_192/document.graphql.dart index 600f39d4..12cbb75f 100644 --- a/packages/graphql_codegen/test/assets/issue_192/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/issue_192/document.graphql.dart @@ -3,7 +3,7 @@ import 'package:gql/ast.dart'; class Query$Q { Query$Q({ this.book, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { @@ -318,7 +318,7 @@ class _CopyWithStubImpl$Query$Q$book class Query$Q$book$$TextBook implements Query$Q$book { Query$Q$book$$TextBook({ this.courses, - required this.$__typename, + this.$__typename = 'TextBook', this.author, }); diff --git a/packages/graphql_codegen/test/assets/issue_206/document.graphql.dart b/packages/graphql_codegen/test/assets/issue_206/document.graphql.dart index 9782b781..49f756b5 100644 --- a/packages/graphql_codegen/test/assets/issue_206/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/issue_206/document.graphql.dart @@ -227,7 +227,7 @@ const documentNodeFragmentEventFragment = DocumentNode(definitions: [ class Fragment$EventFragment$subscription { Fragment$EventFragment$subscription({ required this.notifyFor, - required this.$__typename, + this.$__typename = 'EventSubscription', }); factory Fragment$EventFragment$subscription.fromJson( @@ -354,7 +354,7 @@ class _CopyWithStubImpl$Fragment$EventFragment$subscription class Fragment$EventFragment$$EventPublic implements Fragment$EventFragment { Fragment$EventFragment$$EventPublic({ required this.owner, - required this.$__typename, + this.$__typename = 'EventPublic', this.subscription, }); @@ -530,7 +530,7 @@ class Fragment$EventFragment$$EventPublic$subscription implements Fragment$EventFragment$subscription { Fragment$EventFragment$$EventPublic$subscription({ required this.notifyFor, - required this.$__typename, + this.$__typename = 'EventSubscription', }); factory Fragment$EventFragment$$EventPublic$subscription.fromJson( @@ -658,7 +658,7 @@ class _CopyWithStubImpl$Fragment$EventFragment$$EventPublic$subscription class Fragment$UserPublicFragment { Fragment$UserPublicFragment({ required this.username, - required this.$__typename, + this.$__typename = 'UserPublic', }); factory Fragment$UserPublicFragment.fromJson(Map json) { @@ -812,7 +812,7 @@ const documentNodeFragmentUserPublicFragment = DocumentNode(definitions: [ class Mutation$Bla { Mutation$Bla({ this.bla, - required this.$__typename, + this.$__typename = 'Mutations', }); factory Mutation$Bla.fromJson(Map json) { @@ -1076,7 +1076,7 @@ class Mutation$Bla$bla$$EventPublic Mutation$Bla$bla$$EventPublic({ this.subscription, required this.owner, - required this.$__typename, + this.$__typename = 'EventPublic', }); factory Mutation$Bla$bla$$EventPublic.fromJson(Map json) { @@ -1245,7 +1245,7 @@ class Mutation$Bla$bla$$EventPublic$subscription implements Fragment$EventFragment$$EventPublic$subscription { Mutation$Bla$bla$$EventPublic$subscription({ required this.notifyFor, - required this.$__typename, + this.$__typename = 'EventSubscription', }); factory Mutation$Bla$bla$$EventPublic$subscription.fromJson( diff --git a/packages/graphql_codegen/test/assets/issue_229/lib/generated/schemaA/document.graphql.dart b/packages/graphql_codegen/test/assets/issue_229/lib/generated/schemaA/document.graphql.dart index 66f9162b..cc1059f0 100644 --- a/packages/graphql_codegen/test/assets/issue_229/lib/generated/schemaA/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/issue_229/lib/generated/schemaA/document.graphql.dart @@ -4,7 +4,7 @@ import 'package:graphql/client.dart' as graphql; class Query$Q { Query$Q({ this.q, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/issue_229/lib/generated/schemaB/document.graphql.dart b/packages/graphql_codegen/test/assets/issue_229/lib/generated/schemaB/document.graphql.dart index c11726b1..2ec97e52 100644 --- a/packages/graphql_codegen/test/assets/issue_229/lib/generated/schemaB/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/issue_229/lib/generated/schemaB/document.graphql.dart @@ -4,7 +4,7 @@ import 'package:graphql/client.dart' as graphql; class Query$Q { Query$Q({ this.q, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/issue_239/document.graphql.dart b/packages/graphql_codegen/test/assets/issue_239/document.graphql.dart index 3faed022..6b292bb9 100644 --- a/packages/graphql_codegen/test/assets/issue_239/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/issue_239/document.graphql.dart @@ -3,7 +3,7 @@ import 'package:gql/ast.dart'; class Fragment$HotelBooking { Fragment$HotelBooking({ this.name, - required this.$__typename, + this.$__typename = 'HotelBooking', }); factory Fragment$HotelBooking.fromJson(Map json) { @@ -154,7 +154,7 @@ class Query$Q { Query$Q({ this.booking, this.hotelBooking, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { @@ -469,7 +469,7 @@ class Query$Q$booking$$HotelBooking implements Fragment$HotelBooking, Query$Q$booking { Query$Q$booking$$HotelBooking({ this.name, - required this.$__typename, + this.$__typename = 'HotelBooking', }); factory Query$Q$booking$$HotelBooking.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/json_converters/document.graphql.dart b/packages/graphql_codegen/test/assets/json_converters/document.graphql.dart index f779e7db..82087396 100644 --- a/packages/graphql_codegen/test/assets/json_converters/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/json_converters/document.graphql.dart @@ -8,7 +8,7 @@ class Query$Q { this.mInt, required this.dt, this.mDt, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/lots_of_fragments/document.graphql.dart b/packages/graphql_codegen/test/assets/lots_of_fragments/document.graphql.dart index 092bc56f..81e5320b 100644 --- a/packages/graphql_codegen/test/assets/lots_of_fragments/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/lots_of_fragments/document.graphql.dart @@ -2,7 +2,7 @@ import 'package:gql/ast.dart'; class Fragment$FragmentA implements Fragment$FragmentI$$FieldA { Fragment$FragmentA({ - required this.$__typename, + this.$__typename = 'FieldA', this.value, this.name, }); @@ -331,7 +331,7 @@ const documentNodeFragmentFragmentI = DocumentNode(definitions: [ class Fragment$FragmentI$$FieldA implements Fragment$FragmentI { Fragment$FragmentI$$FieldA({ - required this.$__typename, + this.$__typename = 'FieldA', this.name, }); @@ -454,7 +454,7 @@ class _CopyWithStubImpl$Fragment$FragmentI$$FieldA class Query$FetchStuff { Query$FetchStuff({ - required this.$__typename, + this.$__typename = 'Query', this.field, }); @@ -814,7 +814,7 @@ class Query$FetchStuff$field$$FieldA Fragment$FragmentI$$FieldA, Query$FetchStuff$field { Query$FetchStuff$field$$FieldA({ - required this.$__typename, + this.$__typename = 'FieldA', this.value, this.name, }); diff --git a/packages/graphql_codegen/test/assets/multiple_interfaces/document.graphql.dart b/packages/graphql_codegen/test/assets/multiple_interfaces/document.graphql.dart index 809d9c2f..cba93c00 100644 --- a/packages/graphql_codegen/test/assets/multiple_interfaces/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/multiple_interfaces/document.graphql.dart @@ -949,7 +949,7 @@ class Query$Q$field$$T1 Query$Q$field$$T1({ this.size, this.name, - required this.$__typename, + this.$__typename = 'T1', this.name0, this.name01, this.size2, diff --git a/packages/graphql_codegen/test/assets/naming_config/document.graphql.dart b/packages/graphql_codegen/test/assets/naming_config/document.graphql.dart index 68eabbdd..ebf8d2b3 100644 --- a/packages/graphql_codegen/test/assets/naming_config/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/naming_config/document.graphql.dart @@ -35,7 +35,7 @@ Enum___Status fromJson___Enum___Status(String value) { class Query___Q { Query___Q({ this.status, - required this.$__typename, + this.$__typename = 'Query', }); factory Query___Q.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/nested_inline_and_fragment_spread/document.graphql.dart b/packages/graphql_codegen/test/assets/nested_inline_and_fragment_spread/document.graphql.dart index 9b488345..9857b7d9 100644 --- a/packages/graphql_codegen/test/assets/nested_inline_and_fragment_spread/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/nested_inline_and_fragment_spread/document.graphql.dart @@ -226,7 +226,7 @@ class _CopyWithStubImpl$Fragment$F$t } class Fragment$F$t$t { - Fragment$F$t$t({required this.$__typename}); + Fragment$F$t$t({this.$__typename = 'T'}); factory Fragment$F$t$t.fromJson(Map json) { final l$$__typename = json['__typename']; @@ -655,7 +655,7 @@ class _CopyWithStubImpl$Query$Q$t$t class Query$Q$t$t$t implements Fragment$F$t, Fragment$F$t$t { Query$Q$t$t$t({ this.t, - required this.$__typename, + this.$__typename = 'T', }); factory Query$Q$t$t$t.fromJson(Map json) { @@ -783,7 +783,7 @@ class _CopyWithStubImpl$Query$Q$t$t$t } class Query$Q$t$t$t$t implements Fragment$F$t$t { - Query$Q$t$t$t$t({required this.$__typename}); + Query$Q$t$t$t$t({this.$__typename = 'T'}); factory Query$Q$t$t$t$t.fromJson(Map json) { final l$$__typename = json['__typename']; @@ -1211,7 +1211,7 @@ class _CopyWithStubImpl$Query$Q2$t$t class Query$Q2$t$t$t implements Fragment$F$t$t, Fragment$F$t { Query$Q2$t$t$t({ - required this.$__typename, + this.$__typename = 'T', this.t, }); @@ -1341,7 +1341,7 @@ class _CopyWithStubImpl$Query$Q2$t$t$t } class Query$Q2$t$t$t$t implements Fragment$F$t$t { - Query$Q2$t$t$t$t({required this.$__typename}); + Query$Q2$t$t$t$t({this.$__typename = 'T'}); factory Query$Q2$t$t$t$t.fromJson(Map json) { final l$$__typename = json['__typename']; diff --git a/packages/graphql_codegen/test/assets/output_directory/__generated/folder/document.graphql.dart b/packages/graphql_codegen/test/assets/output_directory/__generated/folder/document.graphql.dart index d1b9e74b..63934c4e 100644 --- a/packages/graphql_codegen/test/assets/output_directory/__generated/folder/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/output_directory/__generated/folder/document.graphql.dart @@ -3,7 +3,7 @@ import 'package:gql/ast.dart'; class Query$Q { Query$Q({ this.name, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/output_directory_2/f2/__generated__/document.graphql.dart b/packages/graphql_codegen/test/assets/output_directory_2/f2/__generated__/document.graphql.dart index db1c8b36..27dbc4c7 100644 --- a/packages/graphql_codegen/test/assets/output_directory_2/f2/__generated__/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/output_directory_2/f2/__generated__/document.graphql.dart @@ -4,7 +4,7 @@ import 'package:gql/ast.dart'; class Query$Q { Query$Q({ this.name, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/query_with_single_fragment/document.graphql.dart b/packages/graphql_codegen/test/assets/query_with_single_fragment/document.graphql.dart index 829b1d4c..4411352c 100644 --- a/packages/graphql_codegen/test/assets/query_with_single_fragment/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/query_with_single_fragment/document.graphql.dart @@ -3,7 +3,7 @@ import 'package:gql/ast.dart'; class Fragment$F { Fragment$F({ this.name, - required this.$__typename, + this.$__typename = 'Query', }); factory Fragment$F.fromJson(Map json) { @@ -149,7 +149,7 @@ const documentNodeFragmentF = DocumentNode(definitions: [ class Query$Q implements Fragment$F { Query$Q({ this.name, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/root_relative_in_lib_output/lib/__generated__/fragments/document.graphql.dart b/packages/graphql_codegen/test/assets/root_relative_in_lib_output/lib/__generated__/fragments/document.graphql.dart index 02c0b2d7..c810997b 100644 --- a/packages/graphql_codegen/test/assets/root_relative_in_lib_output/lib/__generated__/fragments/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/root_relative_in_lib_output/lib/__generated__/fragments/document.graphql.dart @@ -3,7 +3,7 @@ import 'package:gql/ast.dart'; class Fragment$F { Fragment$F({ this.name, - required this.$__typename, + this.$__typename = 'Query', }); factory Fragment$F.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/root_relative_in_lib_output/lib/__generated__/queries/document.graphql.dart b/packages/graphql_codegen/test/assets/root_relative_in_lib_output/lib/__generated__/queries/document.graphql.dart index faa79949..977bc9bc 100644 --- a/packages/graphql_codegen/test/assets/root_relative_in_lib_output/lib/__generated__/queries/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/root_relative_in_lib_output/lib/__generated__/queries/document.graphql.dart @@ -4,7 +4,7 @@ import 'package:gql/ast.dart'; class Query$Q implements Fragment$F { Query$Q({ this.name, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/root_relative_output/lib/__generated__/fragments/document.graphql.dart b/packages/graphql_codegen/test/assets/root_relative_output/lib/__generated__/fragments/document.graphql.dart index 02c0b2d7..c810997b 100644 --- a/packages/graphql_codegen/test/assets/root_relative_output/lib/__generated__/fragments/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/root_relative_output/lib/__generated__/fragments/document.graphql.dart @@ -3,7 +3,7 @@ import 'package:gql/ast.dart'; class Fragment$F { Fragment$F({ this.name, - required this.$__typename, + this.$__typename = 'Query', }); factory Fragment$F.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/root_relative_output/lib/__generated__/queries/document.graphql.dart b/packages/graphql_codegen/test/assets/root_relative_output/lib/__generated__/queries/document.graphql.dart index faa79949..977bc9bc 100644 --- a/packages/graphql_codegen/test/assets/root_relative_output/lib/__generated__/queries/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/root_relative_output/lib/__generated__/queries/document.graphql.dart @@ -4,7 +4,7 @@ import 'package:gql/ast.dart'; class Query$Q implements Fragment$F { Query$Q({ this.name, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$Q.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/scopes/a.query.graphql.dart b/packages/graphql_codegen/test/assets/scopes/a.query.graphql.dart index 71db3dd9..d8cc9deb 100644 --- a/packages/graphql_codegen/test/assets/scopes/a.query.graphql.dart +++ b/packages/graphql_codegen/test/assets/scopes/a.query.graphql.dart @@ -4,7 +4,7 @@ import 'package:gql/ast.dart'; class Query$FetchPerson { Query$FetchPerson({ this.fetchPerson, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$FetchPerson.fromJson(Map json) { @@ -188,7 +188,7 @@ class Query$FetchPerson$fetchPerson { Query$FetchPerson$fetchPerson({ this.name, required this.status, - required this.$__typename, + this.$__typename = 'Person', }); factory Query$FetchPerson$fetchPerson.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/scopes/b.query.graphql.dart b/packages/graphql_codegen/test/assets/scopes/b.query.graphql.dart index 26d45996..20b4e90c 100644 --- a/packages/graphql_codegen/test/assets/scopes/b.query.graphql.dart +++ b/packages/graphql_codegen/test/assets/scopes/b.query.graphql.dart @@ -4,7 +4,7 @@ import 'package:gql/ast.dart'; class Query$FetchPerson { Query$FetchPerson({ this.fetchPerson, - required this.$__typename, + this.$__typename = 'Query', }); factory Query$FetchPerson.fromJson(Map json) { @@ -196,7 +196,7 @@ class Query$FetchPerson$fetchPerson { this.age, this.name, this.status, - required this.$__typename, + this.$__typename = 'Personz', }); factory Query$FetchPerson$fetchPerson.fromJson(Map json) { diff --git a/packages/graphql_codegen/test/assets/unions/document.graphql.dart b/packages/graphql_codegen/test/assets/unions/document.graphql.dart index 8f1179e4..ed4c7068 100644 --- a/packages/graphql_codegen/test/assets/unions/document.graphql.dart +++ b/packages/graphql_codegen/test/assets/unions/document.graphql.dart @@ -249,7 +249,7 @@ class _CopyWithStubImpl$Query$Q$u implements CopyWith$Query$Q$u { class Query$Q$u$$TA implements Query$Q$u { Query$Q$u$$TA({ this.name, - required this.$__typename, + this.$__typename = 'TA', }); factory Query$Q$u$$TA.fromJson(Map json) { @@ -369,7 +369,7 @@ class _CopyWithStubImpl$Query$Q$u$$TA class Query$Q$u$$TB implements Query$Q$u { Query$Q$u$$TB({ this.velocity, - required this.$__typename, + this.$__typename = 'TB', }); factory Query$Q$u$$TB.fromJson(Map json) {