Skip to content

Commit

Permalink
fix(ferry): Fix problem with operationRequest generated on initial re…
Browse files Browse the repository at this point in the history
…quest being included in response each time. (#545)

* fix(ferry)!: Fix problem with operationRequest generated on initial request being included in response each time. This is a breaking change because the received request now has a different object identity and the send request, which some users might have relied on.
  • Loading branch information
YusukeMoriJapan authored Nov 11, 2023
1 parent 97b1f43 commit 701cd33
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 24 deletions.
4 changes: 2 additions & 2 deletions packages/ferry/lib/ferry_isolate.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ class IsolateClient extends TypedLink {
return _handleStreamCommand<OperationResponse<TData, TVars>>(
(port) => RequestCommand(port.sendPort, request),
(response, sink) => sink.add(OperationResponse<TData, TVars>(
operationRequest: request,
linkException: response!.linkException,
operationRequest: response!.operationRequest,
linkException: response.linkException,
graphqlErrors: response.graphqlErrors,
dataSource: response.dataSource,
extensions: response.extensions,
Expand Down
57 changes: 35 additions & 22 deletions packages/ferry/test/isolate/isolate_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,18 +150,26 @@ void main() {
unawaited(expectLater(
stream,
emitsInOrder([
OperationResponse(
data: GHumanWithArgsData((b) => b
..human.id = '1'
..human.name = 'Luke'),
dataSource: DataSource.Link,
operationRequest: req),
OperationResponse(
data: GHumanWithArgsData((b) => b
..human.id = '2'
..human.name = 'Bert'),
dataSource: DataSource.Cache,
operationRequest: req),
isA<OperationResponse<GHumanWithArgsData, GHumanWithArgsVars>>()
.having(
(p) => p.data,
'data',
GHumanWithArgsData((b) => b
..human.id = '1'
..human.name = 'Luke'))
.having((p) => p.linkException, 'linkException', isNull)
.having((p) => p.graphqlErrors, 'errors', isNull)
.having((p) => p.dataSource, 'source', DataSource.Link),
isA<OperationResponse<GHumanWithArgsData, GHumanWithArgsVars>>()
.having(
(p) => p.data,
'data',
GHumanWithArgsData((b) => b
..human.id = '2'
..human.name = 'Bert'))
.having((p) => p.linkException, 'linkException', isNull)
.having((p) => p.graphqlErrors, 'errors', isNull)
.having((p) => p.dataSource, 'source', DataSource.Cache),
emitsDone,
])));

Expand Down Expand Up @@ -189,16 +197,21 @@ void main() {
unawaited(expectLater(
stream,
emitsInOrder([
OperationResponse(
data: GHumanWithArgsData((b) => b
..human.id = '1'
..human.name = 'Luke'),
dataSource: DataSource.Link,
operationRequest: req),
OperationResponse(
operationRequest: req,
data: null,
dataSource: DataSource.Cache),
isA<OperationResponse<GHumanWithArgsData, GHumanWithArgsVars>>()
.having(
(p) => p.data,
'data',
GHumanWithArgsData((b) => b
..human.id = '1'
..human.name = 'Luke'))
.having((p) => p.linkException, 'linkException', isNull)
.having((p) => p.graphqlErrors, 'errors', isNull)
.having((p) => p.dataSource, 'source', DataSource.Link),
isA<OperationResponse<GHumanWithArgsData?, GHumanWithArgsVars>>()
.having((p) => p.data, 'data', isNull)
.having((p) => p.linkException, 'linkException', isNull)
.having((p) => p.graphqlErrors, 'errors', isNull)
.having((p) => p.dataSource, 'source', DataSource.Cache),
emitsDone,
])));

Expand Down

0 comments on commit 701cd33

Please sign in to comment.