Skip to content

Commit

Permalink
feat(ferry_generator): generate varsToJson() method
Browse files Browse the repository at this point in the history
  • Loading branch information
knaeckeKami committed Nov 10, 2023
1 parent fbd0b3f commit 598ddec
Show file tree
Hide file tree
Showing 34 changed files with 235 additions and 7 deletions.
14 changes: 9 additions & 5 deletions packages/ferry_exec/lib/src/json_operation_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import 'package:gql_exec/gql_exec.dart';
/// A [OperationRequest] that parses the response into a [Map<String, dynamic>]
/// this is useful for when you don't have a generated class for the operation
/// or as an escape hatch for when you want to parse the response yourself.
class JsonOperationRequest implements OperationRequest<Map<String, dynamic>, Map<String, dynamic>> {
class JsonOperationRequest
implements OperationRequest<Map<String, dynamic>, Map<String, dynamic>> {
@override
final FetchPolicy fetchPolicy;

Expand All @@ -25,7 +26,8 @@ class JsonOperationRequest implements OperationRequest<Map<String, dynamic>, Map
final Map<String, dynamic> vars;

@override
final Map<String, dynamic>? Function(Map<String, dynamic>?, Map<String, dynamic>?)? updateResult;
final Map<String, dynamic>? Function(
Map<String, dynamic>?, Map<String, dynamic>?)? updateResult;

@override
final Operation operation;
Expand Down Expand Up @@ -62,8 +64,10 @@ class JsonOperationRequest implements OperationRequest<Map<String, dynamic>, Map
o.fetchPolicy == fetchPolicy &&
o.requestId == requestId &&
o.updateCacheHandlerKey == updateCacheHandlerKey &&
o.updateCacheHandlerContext == updateCacheHandlerContext &&
o.executeOnListen == executeOnListen &&
const DeepCollectionEquality().equals(
updateCacheHandlerContext, o.updateCacheHandlerContext) &
o.executeOnListen ==
executeOnListen &&
const DeepCollectionEquality().equals(vars, o.vars) &&
o.updateResult == updateResult &&
o.optimisticResponse == optimisticResponse;
Expand All @@ -75,7 +79,7 @@ class JsonOperationRequest implements OperationRequest<Map<String, dynamic>, Map
fetchPolicy.hashCode ^
requestId.hashCode ^
updateCacheHandlerKey.hashCode ^
updateCacheHandlerContext.hashCode ^
const DeepCollectionEquality().hash(updateCacheHandlerContext) ^
executeOnListen.hashCode ^
const DeepCollectionEquality().hash(vars) ^
updateResult.hashCode ^
Expand Down
1 change: 0 additions & 1 deletion packages/ferry_generator/lib/src/codegen/fragment_req.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ Class _buildFragmentReqClass(
(b) => b
..annotations.add(refer('override'))
..returns = refer('Map<String, dynamic>')
..type = MethodType.getter
..name = 'varsToJson'
..lambda = true
..body = refer('vars').property('toJson').call([]).code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,6 @@ Class _buildOperationReqClass(
(b) => b
..annotations.add(refer('override'))
..returns = refer('Map<String, dynamic>')
..type = MethodType.getter
..name = 'varsToJson'
..lambda = true
..body = (refer('vars').property('toJson').call([])).code,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 598ddec

Please sign in to comment.