Skip to content

Commit dfc1670

Browse files
committed
Let cache watch handle final result
1 parent 8493681 commit dfc1670

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

src/core/ObservableQuery.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -975,24 +975,32 @@ Did you mean to call refetch(variables) instead of refetch({ variables })?`,
975975
if (watch.watcher === this) {
976976
wasUpdated = true;
977977
const lastResult = this.getCurrentResult();
978-
pushNotification({
979-
kind: "N",
980-
source: "network",
981-
value: {
982-
...lastResult,
983-
networkStatus:
984-
fetchMoreResult.networkStatus === NetworkStatus.error ?
985-
NetworkStatus.ready
986-
: fetchMoreResult.networkStatus,
987-
// will be overwritten anyways, just here for types sake
988-
loading: false,
989-
data: diff.result,
990-
dataState:
991-
fetchMoreResult.dataState === "streaming" ?
992-
"streaming"
993-
: "complete",
994-
},
995-
});
978+
979+
// Let the cache watch from resubscribeCache handle the final
980+
// result
981+
if (isNetworkRequestInFlight(fetchMoreResult.networkStatus)) {
982+
pushNotification({
983+
kind: "N",
984+
source: "network",
985+
value: {
986+
...lastResult,
987+
networkStatus:
988+
(
989+
fetchMoreResult.networkStatus ===
990+
NetworkStatus.error
991+
) ?
992+
NetworkStatus.ready
993+
: fetchMoreResult.networkStatus,
994+
// will be overwritten anyways, just here for types sake
995+
loading: false,
996+
data: diff.result,
997+
dataState:
998+
fetchMoreResult.dataState === "streaming" ?
999+
"streaming"
1000+
: "complete",
1001+
},
1002+
});
1003+
}
9961004
}
9971005
},
9981006
});

0 commit comments

Comments
 (0)