From 17b384d52386322905e3d020536e74199de5f49c Mon Sep 17 00:00:00 2001 From: Christian Budde Christensen Date: Thu, 21 Sep 2023 20:46:49 +0100 Subject: [PATCH] fix: Bad mapper for default value --- packages/graphql_codegen/CHANGELOG.md | 4 + packages/graphql_codegen/example/pubspec.lock | 2 +- .../lib/src/context/context.dart | 4 + .../lib/src/printer/base/deep_copy.dart | 2 +- .../lib/src/printer/base/equality.dart | 25 +- .../lib/src/printer/base/utils.dart | 20 + packages/graphql_codegen/pubspec.yaml | 2 +- .../test/assets/issue_309/document.graphql | 19 + .../assets/issue_309/document.graphql.dart | 744 ++++++++++++++++++ packages/graphql_switch/example/pubspec.lock | 2 +- packages/graphql_switch/pubspec.lock | 2 +- 11 files changed, 798 insertions(+), 28 deletions(-) create mode 100644 packages/graphql_codegen/lib/src/printer/base/utils.dart create mode 100644 packages/graphql_codegen/test/assets/issue_309/document.graphql create mode 100644 packages/graphql_codegen/test/assets/issue_309/document.graphql.dart diff --git a/packages/graphql_codegen/CHANGELOG.md b/packages/graphql_codegen/CHANGELOG.md index 04d81897..8807b4a2 100644 --- a/packages/graphql_codegen/CHANGELOG.md +++ b/packages/graphql_codegen/CHANGELOG.md @@ -1,3 +1,7 @@ +# 0.13.6 + +- Fix bad copy class on list with default value. + # 0.13.5 - Run builder before `json_serializable` diff --git a/packages/graphql_codegen/example/pubspec.lock b/packages/graphql_codegen/example/pubspec.lock index 3891ca77..b06ec38f 100644 --- a/packages/graphql_codegen/example/pubspec.lock +++ b/packages/graphql_codegen/example/pubspec.lock @@ -329,7 +329,7 @@ packages: path: ".." relative: true source: path - version: "0.13.5" + version: "0.13.6" graphql_flutter: dependency: "direct main" description: diff --git a/packages/graphql_codegen/lib/src/context/context.dart b/packages/graphql_codegen/lib/src/context/context.dart index 6b3b84a3..739a53be 100644 --- a/packages/graphql_codegen/lib/src/context/context.dart +++ b/packages/graphql_codegen/lib/src/context/context.dart @@ -4,6 +4,7 @@ import 'package:gql/ast.dart'; import 'package:graphql_codegen/src/context/schema.dart'; import 'package:graphql_codegen/src/config/config.dart'; import 'package:graphql_codegen/src/errors.dart'; +import 'package:graphql_codegen/src/printer/base/utils.dart'; import 'package:graphql_codegen/src/transform/add_typename_transforming_visitor.dart'; import 'name.dart'; @@ -161,6 +162,9 @@ class ContextProperty { final List fieldDirectives; final bool hasDefaultValue; + TypeNode get nullableTypeOnDefaultValue => + hasDefaultValue ? typeNodeAsNullable(type) : type; + NameNode get name => alias ?? _name; ContextProperty({ diff --git a/packages/graphql_codegen/lib/src/printer/base/deep_copy.dart b/packages/graphql_codegen/lib/src/printer/base/deep_copy.dart index 1f44e31f..7e8f95c7 100644 --- a/packages/graphql_codegen/lib/src/printer/base/deep_copy.dart +++ b/packages/graphql_codegen/lib/src/printer/base/deep_copy.dart @@ -72,7 +72,7 @@ Method? _printDeepCopyTypeNode( ContextProperty property, bool abstract, ) { - final node = property.type; + final node = property.nullableTypeOnDefaultValue; final namePrinter = printContext.namePrinter; final propertyName = namePrinter.printPropertyName(property.name); final copyClassName = namePrinter.printCopyWithClassName( diff --git a/packages/graphql_codegen/lib/src/printer/base/equality.dart b/packages/graphql_codegen/lib/src/printer/base/equality.dart index 7a1a05ba..3b52dcd2 100644 --- a/packages/graphql_codegen/lib/src/printer/base/equality.dart +++ b/packages/graphql_codegen/lib/src/printer/base/equality.dart @@ -6,25 +6,6 @@ import 'package:graphql_codegen/src/printer/context.dart'; typedef DataObjResolver = Expression Function(); -TypeNode _typeNodeAsNullable(TypeNode node) { - if (!node.isNonNull) { - return node; - } - if (node is ListTypeNode) { - return ListTypeNode( - type: node.type, - isNonNull: false, - ); - } - if (node is NamedTypeNode) { - return NamedTypeNode( - name: node.name, - isNonNull: false, - ); - } - return node; -} - Method printEqualityOperator( PrintContext c, String name, @@ -72,7 +53,7 @@ Method printEqualityOperator( ), ], _printPropertyEqualityCheck( - e.hasDefaultValue ? _typeNodeAsNullable(e.type) : e.type, + e.nullableTypeOnDefaultValue, localThisName, localOtherName, ) @@ -142,9 +123,7 @@ Method printHashCodeMethod( final localProp = context.namePrinter .printLocalPropertyName(property.name); final hash = _printPropertyHash( - property.hasDefaultValue - ? _typeNodeAsNullable(property.type) - : property.type, + property.nullableTypeOnDefaultValue, refer(localProp), ); if (dataObjectCheckResolver != null && diff --git a/packages/graphql_codegen/lib/src/printer/base/utils.dart b/packages/graphql_codegen/lib/src/printer/base/utils.dart new file mode 100644 index 00000000..8ca170e3 --- /dev/null +++ b/packages/graphql_codegen/lib/src/printer/base/utils.dart @@ -0,0 +1,20 @@ +import 'package:gql/ast.dart'; + +TypeNode typeNodeAsNullable(TypeNode node) { + if (!node.isNonNull) { + return node; + } + if (node is ListTypeNode) { + return ListTypeNode( + type: node.type, + isNonNull: false, + ); + } + if (node is NamedTypeNode) { + return NamedTypeNode( + name: node.name, + isNonNull: false, + ); + } + return node; +} diff --git a/packages/graphql_codegen/pubspec.yaml b/packages/graphql_codegen/pubspec.yaml index dd9b6bfb..536c6423 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.13.5 +version: 0.13.6 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/issue_309/document.graphql b/packages/graphql_codegen/test/assets/issue_309/document.graphql new file mode 100644 index 00000000..4d4dd2be --- /dev/null +++ b/packages/graphql_codegen/test/assets/issue_309/document.graphql @@ -0,0 +1,19 @@ +input TemplateDisciplineTopicContentInput { + howStudyIt: String! + infoContentBlocks: [I1!]! + taskContentBlocks: [I2!] + testContentBlocks: [I3!]! = [] + whyStudyIt: String! +} + +input I1 { + data: String +} + +input I2 { + data: String +} + +input I3 { + data: String +} diff --git a/packages/graphql_codegen/test/assets/issue_309/document.graphql.dart b/packages/graphql_codegen/test/assets/issue_309/document.graphql.dart new file mode 100644 index 00000000..0c08dd30 --- /dev/null +++ b/packages/graphql_codegen/test/assets/issue_309/document.graphql.dart @@ -0,0 +1,744 @@ +class Input$TemplateDisciplineTopicContentInput { + factory Input$TemplateDisciplineTopicContentInput({ + required String howStudyIt, + required List infoContentBlocks, + List? taskContentBlocks, + List? testContentBlocks, + required String whyStudyIt, + }) => + Input$TemplateDisciplineTopicContentInput._({ + r'howStudyIt': howStudyIt, + r'infoContentBlocks': infoContentBlocks, + if (taskContentBlocks != null) r'taskContentBlocks': taskContentBlocks, + if (testContentBlocks != null) r'testContentBlocks': testContentBlocks, + r'whyStudyIt': whyStudyIt, + }); + + Input$TemplateDisciplineTopicContentInput._(this._$data); + + factory Input$TemplateDisciplineTopicContentInput.fromJson( + Map data) { + final result$data = {}; + final l$howStudyIt = data['howStudyIt']; + result$data['howStudyIt'] = (l$howStudyIt as String); + final l$infoContentBlocks = data['infoContentBlocks']; + result$data['infoContentBlocks'] = (l$infoContentBlocks as List) + .map((e) => Input$I1.fromJson((e as Map))) + .toList(); + if (data.containsKey('taskContentBlocks')) { + final l$taskContentBlocks = data['taskContentBlocks']; + result$data['taskContentBlocks'] = (l$taskContentBlocks as List?) + ?.map((e) => Input$I2.fromJson((e as Map))) + .toList(); + } + if (data.containsKey('testContentBlocks')) { + final l$testContentBlocks = data['testContentBlocks']; + result$data['testContentBlocks'] = (l$testContentBlocks as List) + .map((e) => Input$I3.fromJson((e as Map))) + .toList(); + } + final l$whyStudyIt = data['whyStudyIt']; + result$data['whyStudyIt'] = (l$whyStudyIt as String); + return Input$TemplateDisciplineTopicContentInput._(result$data); + } + + Map _$data; + + String get howStudyIt => (_$data['howStudyIt'] as String); + List get infoContentBlocks => + (_$data['infoContentBlocks'] as List); + List? get taskContentBlocks => + (_$data['taskContentBlocks'] as List?); + List? get testContentBlocks => + (_$data['testContentBlocks'] as List?); + String get whyStudyIt => (_$data['whyStudyIt'] as String); + Map toJson() { + final result$data = {}; + final l$howStudyIt = howStudyIt; + result$data['howStudyIt'] = l$howStudyIt; + final l$infoContentBlocks = infoContentBlocks; + result$data['infoContentBlocks'] = + l$infoContentBlocks.map((e) => e.toJson()).toList(); + if (_$data.containsKey('taskContentBlocks')) { + final l$taskContentBlocks = taskContentBlocks; + result$data['taskContentBlocks'] = + l$taskContentBlocks?.map((e) => e.toJson()).toList(); + } + if (_$data.containsKey('testContentBlocks')) { + final l$testContentBlocks = testContentBlocks; + result$data['testContentBlocks'] = (l$testContentBlocks as List) + .map((e) => e.toJson()) + .toList(); + } + final l$whyStudyIt = whyStudyIt; + result$data['whyStudyIt'] = l$whyStudyIt; + return result$data; + } + + CopyWith$Input$TemplateDisciplineTopicContentInput< + Input$TemplateDisciplineTopicContentInput> + get copyWith => CopyWith$Input$TemplateDisciplineTopicContentInput( + this, + (i) => i, + ); + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Input$TemplateDisciplineTopicContentInput) || + runtimeType != other.runtimeType) { + return false; + } + final l$howStudyIt = howStudyIt; + final lOther$howStudyIt = other.howStudyIt; + if (l$howStudyIt != lOther$howStudyIt) { + return false; + } + final l$infoContentBlocks = infoContentBlocks; + final lOther$infoContentBlocks = other.infoContentBlocks; + if (l$infoContentBlocks.length != lOther$infoContentBlocks.length) { + return false; + } + for (int i = 0; i < l$infoContentBlocks.length; i++) { + final l$infoContentBlocks$entry = l$infoContentBlocks[i]; + final lOther$infoContentBlocks$entry = lOther$infoContentBlocks[i]; + if (l$infoContentBlocks$entry != lOther$infoContentBlocks$entry) { + return false; + } + } + final l$taskContentBlocks = taskContentBlocks; + final lOther$taskContentBlocks = other.taskContentBlocks; + if (_$data.containsKey('taskContentBlocks') != + other._$data.containsKey('taskContentBlocks')) { + return false; + } + if (l$taskContentBlocks != null && lOther$taskContentBlocks != null) { + if (l$taskContentBlocks.length != lOther$taskContentBlocks.length) { + return false; + } + for (int i = 0; i < l$taskContentBlocks.length; i++) { + final l$taskContentBlocks$entry = l$taskContentBlocks[i]; + final lOther$taskContentBlocks$entry = lOther$taskContentBlocks[i]; + if (l$taskContentBlocks$entry != lOther$taskContentBlocks$entry) { + return false; + } + } + } else if (l$taskContentBlocks != lOther$taskContentBlocks) { + return false; + } + final l$testContentBlocks = testContentBlocks; + final lOther$testContentBlocks = other.testContentBlocks; + if (_$data.containsKey('testContentBlocks') != + other._$data.containsKey('testContentBlocks')) { + return false; + } + if (l$testContentBlocks != null && lOther$testContentBlocks != null) { + if (l$testContentBlocks.length != lOther$testContentBlocks.length) { + return false; + } + for (int i = 0; i < l$testContentBlocks.length; i++) { + final l$testContentBlocks$entry = l$testContentBlocks[i]; + final lOther$testContentBlocks$entry = lOther$testContentBlocks[i]; + if (l$testContentBlocks$entry != lOther$testContentBlocks$entry) { + return false; + } + } + } else if (l$testContentBlocks != lOther$testContentBlocks) { + return false; + } + final l$whyStudyIt = whyStudyIt; + final lOther$whyStudyIt = other.whyStudyIt; + if (l$whyStudyIt != lOther$whyStudyIt) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$howStudyIt = howStudyIt; + final l$infoContentBlocks = infoContentBlocks; + final l$taskContentBlocks = taskContentBlocks; + final l$testContentBlocks = testContentBlocks; + final l$whyStudyIt = whyStudyIt; + return Object.hashAll([ + l$howStudyIt, + Object.hashAll(l$infoContentBlocks.map((v) => v)), + _$data.containsKey('taskContentBlocks') + ? l$taskContentBlocks == null + ? null + : Object.hashAll(l$taskContentBlocks.map((v) => v)) + : const {}, + _$data.containsKey('testContentBlocks') + ? l$testContentBlocks == null + ? null + : Object.hashAll(l$testContentBlocks.map((v) => v)) + : const {}, + l$whyStudyIt, + ]); + } +} + +abstract class CopyWith$Input$TemplateDisciplineTopicContentInput { + factory CopyWith$Input$TemplateDisciplineTopicContentInput( + Input$TemplateDisciplineTopicContentInput instance, + TRes Function(Input$TemplateDisciplineTopicContentInput) then, + ) = _CopyWithImpl$Input$TemplateDisciplineTopicContentInput; + + factory CopyWith$Input$TemplateDisciplineTopicContentInput.stub(TRes res) = + _CopyWithStubImpl$Input$TemplateDisciplineTopicContentInput; + + TRes call({ + String? howStudyIt, + List? infoContentBlocks, + List? taskContentBlocks, + List? testContentBlocks, + String? whyStudyIt, + }); + TRes infoContentBlocks( + Iterable Function(Iterable>) _fn); + TRes taskContentBlocks( + Iterable? Function(Iterable>?) _fn); + TRes testContentBlocks( + Iterable? Function(Iterable>?) _fn); +} + +class _CopyWithImpl$Input$TemplateDisciplineTopicContentInput + implements CopyWith$Input$TemplateDisciplineTopicContentInput { + _CopyWithImpl$Input$TemplateDisciplineTopicContentInput( + this._instance, + this._then, + ); + + final Input$TemplateDisciplineTopicContentInput _instance; + + final TRes Function(Input$TemplateDisciplineTopicContentInput) _then; + + static const _undefined = {}; + + TRes call({ + Object? howStudyIt = _undefined, + Object? infoContentBlocks = _undefined, + Object? taskContentBlocks = _undefined, + Object? testContentBlocks = _undefined, + Object? whyStudyIt = _undefined, + }) => + _then(Input$TemplateDisciplineTopicContentInput._({ + ..._instance._$data, + if (howStudyIt != _undefined && howStudyIt != null) + 'howStudyIt': (howStudyIt as String), + if (infoContentBlocks != _undefined && infoContentBlocks != null) + 'infoContentBlocks': (infoContentBlocks as List), + if (taskContentBlocks != _undefined) + 'taskContentBlocks': (taskContentBlocks as List?), + if (testContentBlocks != _undefined && testContentBlocks != null) + 'testContentBlocks': (testContentBlocks as List), + if (whyStudyIt != _undefined && whyStudyIt != null) + 'whyStudyIt': (whyStudyIt as String), + })); + TRes infoContentBlocks( + Iterable Function(Iterable>) + _fn) => + call( + infoContentBlocks: + _fn(_instance.infoContentBlocks.map((e) => CopyWith$Input$I1( + e, + (i) => i, + ))).toList()); + TRes taskContentBlocks( + Iterable? Function(Iterable>?) + _fn) => + call( + taskContentBlocks: + _fn(_instance.taskContentBlocks?.map((e) => CopyWith$Input$I2( + e, + (i) => i, + )))?.toList()); + TRes testContentBlocks( + Iterable? Function(Iterable>?) + _fn) => + call( + testContentBlocks: + _fn(_instance.testContentBlocks?.map((e) => CopyWith$Input$I3( + e, + (i) => i, + )))?.toList()); +} + +class _CopyWithStubImpl$Input$TemplateDisciplineTopicContentInput + implements CopyWith$Input$TemplateDisciplineTopicContentInput { + _CopyWithStubImpl$Input$TemplateDisciplineTopicContentInput(this._res); + + TRes _res; + + call({ + String? howStudyIt, + List? infoContentBlocks, + List? taskContentBlocks, + List? testContentBlocks, + String? whyStudyIt, + }) => + _res; + infoContentBlocks(_fn) => _res; + taskContentBlocks(_fn) => _res; + testContentBlocks(_fn) => _res; +} + +class Input$I1 { + factory Input$I1({String? data}) => Input$I1._({ + if (data != null) r'data': data, + }); + + Input$I1._(this._$data); + + factory Input$I1.fromJson(Map data) { + final result$data = {}; + if (data.containsKey('data')) { + final l$data = data['data']; + result$data['data'] = (l$data as String?); + } + return Input$I1._(result$data); + } + + Map _$data; + + String? get data => (_$data['data'] as String?); + Map toJson() { + final result$data = {}; + if (_$data.containsKey('data')) { + final l$data = data; + result$data['data'] = l$data; + } + return result$data; + } + + CopyWith$Input$I1 get copyWith => CopyWith$Input$I1( + this, + (i) => i, + ); + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Input$I1) || runtimeType != other.runtimeType) { + return false; + } + final l$data = data; + final lOther$data = other.data; + if (_$data.containsKey('data') != other._$data.containsKey('data')) { + return false; + } + if (l$data != lOther$data) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$data = data; + return Object.hashAll([_$data.containsKey('data') ? l$data : const {}]); + } +} + +abstract class CopyWith$Input$I1 { + factory CopyWith$Input$I1( + Input$I1 instance, + TRes Function(Input$I1) then, + ) = _CopyWithImpl$Input$I1; + + factory CopyWith$Input$I1.stub(TRes res) = _CopyWithStubImpl$Input$I1; + + TRes call({String? data}); +} + +class _CopyWithImpl$Input$I1 implements CopyWith$Input$I1 { + _CopyWithImpl$Input$I1( + this._instance, + this._then, + ); + + final Input$I1 _instance; + + final TRes Function(Input$I1) _then; + + static const _undefined = {}; + + TRes call({Object? data = _undefined}) => _then(Input$I1._({ + ..._instance._$data, + if (data != _undefined) 'data': (data as String?), + })); +} + +class _CopyWithStubImpl$Input$I1 implements CopyWith$Input$I1 { + _CopyWithStubImpl$Input$I1(this._res); + + TRes _res; + + call({String? data}) => _res; +} + +class Input$I2 { + factory Input$I2({String? data}) => Input$I2._({ + if (data != null) r'data': data, + }); + + Input$I2._(this._$data); + + factory Input$I2.fromJson(Map data) { + final result$data = {}; + if (data.containsKey('data')) { + final l$data = data['data']; + result$data['data'] = (l$data as String?); + } + return Input$I2._(result$data); + } + + Map _$data; + + String? get data => (_$data['data'] as String?); + Map toJson() { + final result$data = {}; + if (_$data.containsKey('data')) { + final l$data = data; + result$data['data'] = l$data; + } + return result$data; + } + + CopyWith$Input$I2 get copyWith => CopyWith$Input$I2( + this, + (i) => i, + ); + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Input$I2) || runtimeType != other.runtimeType) { + return false; + } + final l$data = data; + final lOther$data = other.data; + if (_$data.containsKey('data') != other._$data.containsKey('data')) { + return false; + } + if (l$data != lOther$data) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$data = data; + return Object.hashAll([_$data.containsKey('data') ? l$data : const {}]); + } +} + +abstract class CopyWith$Input$I2 { + factory CopyWith$Input$I2( + Input$I2 instance, + TRes Function(Input$I2) then, + ) = _CopyWithImpl$Input$I2; + + factory CopyWith$Input$I2.stub(TRes res) = _CopyWithStubImpl$Input$I2; + + TRes call({String? data}); +} + +class _CopyWithImpl$Input$I2 implements CopyWith$Input$I2 { + _CopyWithImpl$Input$I2( + this._instance, + this._then, + ); + + final Input$I2 _instance; + + final TRes Function(Input$I2) _then; + + static const _undefined = {}; + + TRes call({Object? data = _undefined}) => _then(Input$I2._({ + ..._instance._$data, + if (data != _undefined) 'data': (data as String?), + })); +} + +class _CopyWithStubImpl$Input$I2 implements CopyWith$Input$I2 { + _CopyWithStubImpl$Input$I2(this._res); + + TRes _res; + + call({String? data}) => _res; +} + +class Input$I3 { + factory Input$I3({String? data}) => Input$I3._({ + if (data != null) r'data': data, + }); + + Input$I3._(this._$data); + + factory Input$I3.fromJson(Map data) { + final result$data = {}; + if (data.containsKey('data')) { + final l$data = data['data']; + result$data['data'] = (l$data as String?); + } + return Input$I3._(result$data); + } + + Map _$data; + + String? get data => (_$data['data'] as String?); + Map toJson() { + final result$data = {}; + if (_$data.containsKey('data')) { + final l$data = data; + result$data['data'] = l$data; + } + return result$data; + } + + CopyWith$Input$I3 get copyWith => CopyWith$Input$I3( + this, + (i) => i, + ); + @override + bool operator ==(Object other) { + if (identical(this, other)) { + return true; + } + if (!(other is Input$I3) || runtimeType != other.runtimeType) { + return false; + } + final l$data = data; + final lOther$data = other.data; + if (_$data.containsKey('data') != other._$data.containsKey('data')) { + return false; + } + if (l$data != lOther$data) { + return false; + } + return true; + } + + @override + int get hashCode { + final l$data = data; + return Object.hashAll([_$data.containsKey('data') ? l$data : const {}]); + } +} + +abstract class CopyWith$Input$I3 { + factory CopyWith$Input$I3( + Input$I3 instance, + TRes Function(Input$I3) then, + ) = _CopyWithImpl$Input$I3; + + factory CopyWith$Input$I3.stub(TRes res) = _CopyWithStubImpl$Input$I3; + + TRes call({String? data}); +} + +class _CopyWithImpl$Input$I3 implements CopyWith$Input$I3 { + _CopyWithImpl$Input$I3( + this._instance, + this._then, + ); + + final Input$I3 _instance; + + final TRes Function(Input$I3) _then; + + static const _undefined = {}; + + TRes call({Object? data = _undefined}) => _then(Input$I3._({ + ..._instance._$data, + if (data != _undefined) 'data': (data as String?), + })); +} + +class _CopyWithStubImpl$Input$I3 implements CopyWith$Input$I3 { + _CopyWithStubImpl$Input$I3(this._res); + + TRes _res; + + call({String? data}) => _res; +} + +enum Enum$__TypeKind { + SCALAR, + OBJECT, + INTERFACE, + UNION, + ENUM, + INPUT_OBJECT, + LIST, + NON_NULL, + $unknown +} + +String toJson$Enum$__TypeKind(Enum$__TypeKind e) { + switch (e) { + case Enum$__TypeKind.SCALAR: + return r'SCALAR'; + case Enum$__TypeKind.OBJECT: + return r'OBJECT'; + case Enum$__TypeKind.INTERFACE: + return r'INTERFACE'; + case Enum$__TypeKind.UNION: + return r'UNION'; + case Enum$__TypeKind.ENUM: + return r'ENUM'; + case Enum$__TypeKind.INPUT_OBJECT: + return r'INPUT_OBJECT'; + case Enum$__TypeKind.LIST: + return r'LIST'; + case Enum$__TypeKind.NON_NULL: + return r'NON_NULL'; + case Enum$__TypeKind.$unknown: + return r'$unknown'; + } +} + +Enum$__TypeKind fromJson$Enum$__TypeKind(String value) { + switch (value) { + case r'SCALAR': + return Enum$__TypeKind.SCALAR; + case r'OBJECT': + return Enum$__TypeKind.OBJECT; + case r'INTERFACE': + return Enum$__TypeKind.INTERFACE; + case r'UNION': + return Enum$__TypeKind.UNION; + case r'ENUM': + return Enum$__TypeKind.ENUM; + case r'INPUT_OBJECT': + return Enum$__TypeKind.INPUT_OBJECT; + case r'LIST': + return Enum$__TypeKind.LIST; + case r'NON_NULL': + return Enum$__TypeKind.NON_NULL; + default: + return Enum$__TypeKind.$unknown; + } +} + +enum Enum$__DirectiveLocation { + QUERY, + MUTATION, + SUBSCRIPTION, + FIELD, + FRAGMENT_DEFINITION, + FRAGMENT_SPREAD, + INLINE_FRAGMENT, + VARIABLE_DEFINITION, + SCHEMA, + SCALAR, + OBJECT, + FIELD_DEFINITION, + ARGUMENT_DEFINITION, + INTERFACE, + UNION, + ENUM, + ENUM_VALUE, + INPUT_OBJECT, + INPUT_FIELD_DEFINITION, + $unknown +} + +String toJson$Enum$__DirectiveLocation(Enum$__DirectiveLocation e) { + switch (e) { + case Enum$__DirectiveLocation.QUERY: + return r'QUERY'; + case Enum$__DirectiveLocation.MUTATION: + return r'MUTATION'; + case Enum$__DirectiveLocation.SUBSCRIPTION: + return r'SUBSCRIPTION'; + case Enum$__DirectiveLocation.FIELD: + return r'FIELD'; + case Enum$__DirectiveLocation.FRAGMENT_DEFINITION: + return r'FRAGMENT_DEFINITION'; + case Enum$__DirectiveLocation.FRAGMENT_SPREAD: + return r'FRAGMENT_SPREAD'; + case Enum$__DirectiveLocation.INLINE_FRAGMENT: + return r'INLINE_FRAGMENT'; + case Enum$__DirectiveLocation.VARIABLE_DEFINITION: + return r'VARIABLE_DEFINITION'; + case Enum$__DirectiveLocation.SCHEMA: + return r'SCHEMA'; + case Enum$__DirectiveLocation.SCALAR: + return r'SCALAR'; + case Enum$__DirectiveLocation.OBJECT: + return r'OBJECT'; + case Enum$__DirectiveLocation.FIELD_DEFINITION: + return r'FIELD_DEFINITION'; + case Enum$__DirectiveLocation.ARGUMENT_DEFINITION: + return r'ARGUMENT_DEFINITION'; + case Enum$__DirectiveLocation.INTERFACE: + return r'INTERFACE'; + case Enum$__DirectiveLocation.UNION: + return r'UNION'; + case Enum$__DirectiveLocation.ENUM: + return r'ENUM'; + case Enum$__DirectiveLocation.ENUM_VALUE: + return r'ENUM_VALUE'; + case Enum$__DirectiveLocation.INPUT_OBJECT: + return r'INPUT_OBJECT'; + case Enum$__DirectiveLocation.INPUT_FIELD_DEFINITION: + return r'INPUT_FIELD_DEFINITION'; + case Enum$__DirectiveLocation.$unknown: + return r'$unknown'; + } +} + +Enum$__DirectiveLocation fromJson$Enum$__DirectiveLocation(String value) { + switch (value) { + case r'QUERY': + return Enum$__DirectiveLocation.QUERY; + case r'MUTATION': + return Enum$__DirectiveLocation.MUTATION; + case r'SUBSCRIPTION': + return Enum$__DirectiveLocation.SUBSCRIPTION; + case r'FIELD': + return Enum$__DirectiveLocation.FIELD; + case r'FRAGMENT_DEFINITION': + return Enum$__DirectiveLocation.FRAGMENT_DEFINITION; + case r'FRAGMENT_SPREAD': + return Enum$__DirectiveLocation.FRAGMENT_SPREAD; + case r'INLINE_FRAGMENT': + return Enum$__DirectiveLocation.INLINE_FRAGMENT; + case r'VARIABLE_DEFINITION': + return Enum$__DirectiveLocation.VARIABLE_DEFINITION; + case r'SCHEMA': + return Enum$__DirectiveLocation.SCHEMA; + case r'SCALAR': + return Enum$__DirectiveLocation.SCALAR; + case r'OBJECT': + return Enum$__DirectiveLocation.OBJECT; + case r'FIELD_DEFINITION': + return Enum$__DirectiveLocation.FIELD_DEFINITION; + case r'ARGUMENT_DEFINITION': + return Enum$__DirectiveLocation.ARGUMENT_DEFINITION; + case r'INTERFACE': + return Enum$__DirectiveLocation.INTERFACE; + case r'UNION': + return Enum$__DirectiveLocation.UNION; + case r'ENUM': + return Enum$__DirectiveLocation.ENUM; + case r'ENUM_VALUE': + return Enum$__DirectiveLocation.ENUM_VALUE; + case r'INPUT_OBJECT': + return Enum$__DirectiveLocation.INPUT_OBJECT; + case r'INPUT_FIELD_DEFINITION': + return Enum$__DirectiveLocation.INPUT_FIELD_DEFINITION; + default: + return Enum$__DirectiveLocation.$unknown; + } +} + +const possibleTypesMap = >{}; diff --git a/packages/graphql_switch/example/pubspec.lock b/packages/graphql_switch/example/pubspec.lock index 0720d430..2cdd2282 100644 --- a/packages/graphql_switch/example/pubspec.lock +++ b/packages/graphql_switch/example/pubspec.lock @@ -300,7 +300,7 @@ packages: path: "../../graphql_codegen" relative: true source: path - version: "0.13.5" + version: "0.13.6" graphql_switch: dependency: "direct main" description: diff --git a/packages/graphql_switch/pubspec.lock b/packages/graphql_switch/pubspec.lock index 8da4a81b..8f82d2fe 100644 --- a/packages/graphql_switch/pubspec.lock +++ b/packages/graphql_switch/pubspec.lock @@ -316,7 +316,7 @@ packages: path: "../graphql_codegen" relative: true source: path - version: "0.13.5" + version: "0.13.6" graphs: dependency: transitive description: