Skip to content

Commit

Permalink
Minor refactor to reuse value
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed May 13, 2024
1 parent e387903 commit 10d88be
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/cache/core/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,23 +229,21 @@ export abstract class ApolloCache<TSerialized> implements DataProxy {
options: WatchFragmentOptions<TData, TVars>
): Observable<WatchFragmentResult<TData>> {
const { fragment, fragmentName, from, optimistic = true } = options;
const query = this.getFragmentDoc(fragment, fragmentName);

const diffOptions: Cache.DiffOptions<TData, TVars> = {
returnPartialData: true,
id: typeof from === "string" ? from : this.identify(from),
query: this.getFragmentDoc(fragment, fragmentName),
query,
optimistic,
};

let latestDiff: DataProxy.DiffResult<TData> | undefined;

return new Observable((observer) => {
const query = this.getFragmentDoc(fragment, fragmentName);

return this.watch<TData, TVars>({
...diffOptions,
immediate: true,
query,
callback(diff) {
if (
// Always ensure we deliver the first result
Expand Down

0 comments on commit 10d88be

Please sign in to comment.