Skip to content

Commit

Permalink
Merge pull request #321 from comigor/fix_177
Browse files Browse the repository at this point in the history
Fix #177
  • Loading branch information
vasilich6107 committed Jun 10, 2021
2 parents 7681014 + 9d43e69 commit 795aa7f
Show file tree
Hide file tree
Showing 53 changed files with 181 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# CHANGELOG

## 7.0.0-beta.13

- fix for https://github.com/comigor/artemis/issues/177

## 7.0.0-beta.12

- package update
Expand Down
2 changes: 2 additions & 0 deletions lib/generator/print_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,15 @@ Spec classDefinitionToSpec(
? Method(
(m) => m
..name = 'toJson'
..annotations.add(CodeExpression(Code('override')))
..returns = refer('Map<String, dynamic>')
..body = Code(_toJsonBody(definition)),
)
: Method(
(m) => m
..name = 'toJson'
..lambda = true
..annotations.add(CodeExpression(Code('override')))
..returns = refer('Map<String, dynamic>')
..body = Code('_\$${definition.name.namePrintable}ToJson(this)'),
);
Expand Down
2 changes: 0 additions & 2 deletions lib/schema/graphql_response.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import 'package:gql_exec/gql_exec.dart';
import 'package:meta/meta.dart';

/// Encapsulates a GraphQL query/mutation response from server, with typed
/// input and responses, and errors.
@immutable
class GraphQLResponse<T> {
/// The typed data of this response.
final T? data;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: artemis
version: 7.0.0-beta.12
version: 7.0.0-beta.13

description: Build dart types from GraphQL schemas and queries (using Introspection Query).
homepage: https://github.com/comigor/artemis
Expand Down
8 changes: 8 additions & 0 deletions test/generator/print_helpers_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class AClass extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [];
@override
Map<String, dynamic> toJson() => _\$AClassToJson(this);
}
''');
Expand All @@ -170,6 +171,7 @@ class AClass extends AnotherClass with EquatableMixin {
@override
List<Object?> get props => [];
@override
Map<String, dynamic> toJson() => _\$AClassToJson(this);
}
''');
Expand Down Expand Up @@ -207,6 +209,7 @@ class AClass extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [];
@override
Map<String, dynamic> toJson() {
switch ($$typename) {
case r'ASubClass':
Expand Down Expand Up @@ -246,6 +249,7 @@ class AClass extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [name, anotherName];
@override
Map<String, dynamic> toJson() => _\$AClassToJson(this);
}
''');
Expand Down Expand Up @@ -295,6 +299,7 @@ class AClass extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [name, name, name, name];
@override
Map<String, dynamic> toJson() => _\$AClassToJson(this);
}
''');
Expand Down Expand Up @@ -326,6 +331,7 @@ class AClass extends JsonSerializable with EquatableMixin, FragmentMixin {
@override
List<Object?> get props => [name];
@override
Map<String, dynamic> toJson() => _\$AClassToJson(this);
}
''');
Expand Down Expand Up @@ -360,6 +366,7 @@ class AClass extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [name, anotherName];
@override
Map<String, dynamic> toJson() => _\$AClassToJson(this);
}
''');
Expand Down Expand Up @@ -682,6 +689,7 @@ class AClass extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [];
@override
Map<String, dynamic> toJson() => _\$AClassToJson(this);
}
Expand Down
2 changes: 2 additions & 0 deletions test/query_generator/aliases/alias_on_leaves_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class SomeQuery$Response$SomeObject extends JsonSerializable
@override
List<Object?> get props => [thisIsAnEnum];
@override
Map<String, dynamic> toJson() => _$SomeQuery$Response$SomeObjectToJson(this);
}
Expand All @@ -134,6 +135,7 @@ class SomeQuery$Response extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [thisIsAString, o];
@override
Map<String, dynamic> toJson() => _$SomeQuery$ResponseToJson(this);
}
Expand Down
3 changes: 3 additions & 0 deletions test/query_generator/aliases/alias_on_object_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class SomeQuery$QueryResponse$SomeObject extends JsonSerializable
@override
List<Object?> get props => [st];
@override
Map<String, dynamic> toJson() =>
_$SomeQuery$QueryResponse$SomeObjectToJson(this);
}
Expand All @@ -137,6 +138,7 @@ class SomeQuery$QueryResponse$AnotherObject extends JsonSerializable
@override
List<Object?> get props => [str];
@override
Map<String, dynamic> toJson() =>
_$SomeQuery$QueryResponse$AnotherObjectToJson(this);
}
Expand All @@ -156,6 +158,7 @@ class SomeQuery$QueryResponse extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [s, o, anotherObject];
@override
Map<String, dynamic> toJson() => _$SomeQuery$QueryResponseToJson(this);
}
''';
12 changes: 12 additions & 0 deletions test/query_generator/append_type_name_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class Custom$QueryRoot$Q extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [e, $$typename];
@override
Map<String, dynamic> toJson() => _$Custom$QueryRoot$QToJson(this);
}
Expand All @@ -111,6 +112,7 @@ class Custom$QueryRoot extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [q, $$typename];
@override
Map<String, dynamic> toJson() => _$Custom$QueryRootToJson(this);
}
''',
Expand Down Expand Up @@ -207,6 +209,7 @@ class Custom$QueryRoot$Q extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [e, $$typename];
@override
Map<String, dynamic> toJson() => _$Custom$QueryRoot$QToJson(this);
}
Expand All @@ -224,6 +227,7 @@ class Custom$QueryRoot extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [q, $$typename];
@override
Map<String, dynamic> toJson() => _$Custom$QueryRootToJson(this);
}
''',
Expand Down Expand Up @@ -337,6 +341,7 @@ class Custom$QueryRoot$Q extends JsonSerializable
@override
List<Object?> get props => [e, $$typename, $$typename];
@override
Map<String, dynamic> toJson() => _$Custom$QueryRoot$QToJson(this);
}
Expand All @@ -354,6 +359,7 @@ class Custom$QueryRoot extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [q, $$typename];
@override
Map<String, dynamic> toJson() => _$Custom$QueryRootToJson(this);
}
''',
Expand Down Expand Up @@ -495,6 +501,7 @@ class Custom$QueryRoot$Q$TypeA extends Custom$QueryRoot$Q with EquatableMixin {
@override
List<Object?> get props => [a, $$typename];
@override
Map<String, dynamic> toJson() => _$Custom$QueryRoot$Q$TypeAToJson(this);
}
Expand All @@ -513,6 +520,7 @@ class Custom$QueryRoot$Q$TypeB extends Custom$QueryRoot$Q with EquatableMixin {
@override
List<Object?> get props => [b, $$typename];
@override
Map<String, dynamic> toJson() => _$Custom$QueryRoot$Q$TypeBToJson(this);
}
Expand All @@ -536,6 +544,7 @@ class Custom$QueryRoot$Q extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [$$typename];
@override
Map<String, dynamic> toJson() {
switch ($$typename) {
case r'TypeA':
Expand All @@ -562,6 +571,7 @@ class Custom$QueryRoot extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [q, $$typename];
@override
Map<String, dynamic> toJson() => _$Custom$QueryRootToJson(this);
}
''',
Expand Down Expand Up @@ -672,6 +682,7 @@ class Custom$QueryRoot$QueryResponse extends JsonSerializable
@override
List<Object?> get props => [e, $$typename, $$typename];
@override
Map<String, dynamic> toJson() => _$Custom$QueryRoot$QueryResponseToJson(this);
}
Expand All @@ -689,6 +700,7 @@ class Custom$QueryRoot extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [q, $$typename];
@override
Map<String, dynamic> toJson() => _$Custom$QueryRootToJson(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ class CreateThing$MutationRoot$CreateThingResponse$Thing
@override
List<Object?> get props => [id, message];
@override
Map<String, dynamic> toJson() =>
_$CreateThing$MutationRoot$CreateThingResponse$ThingToJson(this);
}
Expand All @@ -163,6 +164,7 @@ class CreateThing$MutationRoot$CreateThingResponse extends JsonSerializable
@override
List<Object?> get props => [thing];
@override
Map<String, dynamic> toJson() =>
_$CreateThing$MutationRoot$CreateThingResponseToJson(this);
}
Expand All @@ -178,6 +180,7 @@ class CreateThing$MutationRoot extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [createThing];
@override
Map<String, dynamic> toJson() => _$CreateThing$MutationRootToJson(this);
}
Expand All @@ -194,6 +197,7 @@ class CreateThingInput extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [clientId, message];
@override
Map<String, dynamic> toJson() => _$CreateThingInputToJson(this);
}
''';
5 changes: 5 additions & 0 deletions test/query_generator/ast_schema/input_types_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class CreateThing$MutationRoot$CreateThingResponse$Thing
@override
List<Object?> get props => [id, message];
@override
Map<String, dynamic> toJson() =>
_$CreateThing$MutationRoot$CreateThingResponse$ThingToJson(this);
}
Expand All @@ -186,6 +187,7 @@ class CreateThing$MutationRoot$CreateThingResponse extends JsonSerializable
@override
List<Object?> get props => [thing];
@override
Map<String, dynamic> toJson() =>
_$CreateThing$MutationRoot$CreateThingResponseToJson(this);
}
Expand All @@ -201,6 +203,7 @@ class CreateThing$MutationRoot extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [createThing];
@override
Map<String, dynamic> toJson() => _$CreateThing$MutationRootToJson(this);
}
Expand All @@ -215,6 +218,7 @@ class OtherObjectInput extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [id];
@override
Map<String, dynamic> toJson() => _$OtherObjectInputToJson(this);
}
Expand All @@ -233,6 +237,7 @@ class CreateThingInput extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [clientId, message, shares];
@override
Map<String, dynamic> toJson() => _$CreateThingInputToJson(this);
}
''';
1 change: 1 addition & 0 deletions test/query_generator/ast_schema/missing_schema_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Query$Query extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [a];
@override
Map<String, dynamic> toJson() => _$Query$QueryToJson(this);
}
''';
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ class BrowseArticles$Query$Articles extends JsonSerializable
@override
List<Object?> get props => [id, title, articleType];
@override
Map<String, dynamic> toJson() => _$BrowseArticles$Query$ArticlesToJson(this);
}
Expand All @@ -332,6 +333,7 @@ class BrowseArticles$Query extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [articles];
@override
Map<String, dynamic> toJson() => _$BrowseArticles$QueryToJson(this);
}
Expand Down Expand Up @@ -426,6 +428,7 @@ class BrowseRepositories$Query$Repositories extends JsonSerializable
@override
List<Object?> get props => [id, title, privacy, status];
@override
Map<String, dynamic> toJson() =>
_$BrowseRepositories$Query$RepositoriesToJson(this);
}
Expand All @@ -441,6 +444,7 @@ class BrowseRepositories$Query extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [repositories];
@override
Map<String, dynamic> toJson() => _$BrowseRepositories$QueryToJson(this);
}
Expand All @@ -458,6 +462,7 @@ class NotificationOptionInput extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [type, enabled];
@override
Map<String, dynamic> toJson() => _$NotificationOptionInputToJson(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ class SomeQuery$QueryResponse extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [someValue];
@override
Map<String, dynamic> toJson() => _$SomeQuery$QueryResponseToJson(this);
}
Expand Down
3 changes: 3 additions & 0 deletions test/query_generator/deprecated/deprecated_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class SomeQuery$QueryResponse$DeprecatedObject extends JsonSerializable
@override
List<Object?> get props => [someField, deprecatedField];
@override
Map<String, dynamic> toJson() =>
_$SomeQuery$QueryResponse$DeprecatedObjectToJson(this);
}
Expand All @@ -152,6 +153,7 @@ class SomeQuery$QueryResponse$SomeObject extends JsonSerializable
@override
List<Object?> get props => [someField, deprecatedField];
@override
Map<String, dynamic> toJson() =>
_$SomeQuery$QueryResponse$SomeObjectToJson(this);
}
Expand All @@ -170,6 +172,7 @@ class SomeQuery$QueryResponse extends JsonSerializable with EquatableMixin {
@override
List<Object?> get props => [deprecatedObject, someObjects];
@override
Map<String, dynamic> toJson() => _$SomeQuery$QueryResponseToJson(this);
}
''';
Loading

0 comments on commit 795aa7f

Please sign in to comment.