-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ff0655
commit f7d87a2
Showing
23 changed files
with
591 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import 'package:collection/collection.dart'; | ||
import 'package:ferry_exec/ferry_exec.dart'; | ||
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>> { | ||
@override | ||
final FetchPolicy fetchPolicy; | ||
|
||
@override | ||
final String? requestId; | ||
|
||
@override | ||
final String? updateCacheHandlerKey; | ||
|
||
@override | ||
final Map<String, dynamic>? updateCacheHandlerContext; | ||
|
||
@override | ||
final bool executeOnListen; | ||
|
||
@override | ||
final Map<String, dynamic> vars; | ||
|
||
@override | ||
final Map<String, dynamic>? Function(Map<String, dynamic>?, Map<String, dynamic>?)? updateResult; | ||
|
||
@override | ||
final Operation operation; | ||
|
||
@override | ||
Request get execRequest => Request(operation: operation, variables: vars); | ||
|
||
JsonOperationRequest( | ||
{required this.operation, | ||
required this.fetchPolicy, | ||
required this.requestId, | ||
this.updateCacheHandlerKey, | ||
this.updateCacheHandlerContext, | ||
this.executeOnListen = true, | ||
required this.vars, | ||
this.updateResult, | ||
this.optimisticResponse}); | ||
|
||
@override | ||
Map<String, dynamic> parseData(Map<String, dynamic> json) => json; | ||
|
||
@override | ||
final Map<String, dynamic>? optimisticResponse; | ||
|
||
@override | ||
Map<String, dynamic> varsToJson() => vars; | ||
|
||
@override | ||
bool operator ==(Object o) { | ||
if (identical(this, o)) return true; | ||
|
||
return o is JsonOperationRequest && | ||
o.operation == operation && | ||
o.fetchPolicy == fetchPolicy && | ||
o.requestId == requestId && | ||
o.updateCacheHandlerKey == updateCacheHandlerKey && | ||
o.updateCacheHandlerContext == updateCacheHandlerContext && | ||
o.executeOnListen == executeOnListen && | ||
const DeepCollectionEquality().equals(vars, o.vars) && | ||
o.updateResult == updateResult && | ||
o.optimisticResponse == optimisticResponse; | ||
} | ||
|
||
@override | ||
int get hashCode { | ||
return operation.hashCode ^ | ||
fetchPolicy.hashCode ^ | ||
requestId.hashCode ^ | ||
updateCacheHandlerKey.hashCode ^ | ||
updateCacheHandlerContext.hashCode ^ | ||
executeOnListen.hashCode ^ | ||
const DeepCollectionEquality().hash(vars) ^ | ||
updateResult.hashCode ^ | ||
optimisticResponse.hashCode; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Dart | ||
.dart_tool | ||
.packages | ||
pubspec.lock | ||
|
||
# Documentation | ||
doc/api | ||
|
||
build/ |
Oops, something went wrong.