Skip to content

Commit 55b3707

Browse files
committed
Early return
1 parent 2cfe448 commit 55b3707

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

src/core/MutationResponse.ts

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -237,33 +237,36 @@ export class MutationResponse<
237237
if (!queryName || !Object.hasOwn(updateQueries, queryName)) {
238238
return;
239239
}
240-
const updater = updateQueries[queryName];
241-
const { query: document, variables } = observableQuery;
242240

243241
// Read the current query result from the store.
244242
const { result: currentQueryResult, complete } =
245243
observableQuery.getCacheDiff({ optimistic: false });
246244

247-
if (complete && currentQueryResult) {
248-
// Run our reducer using the current query result and the mutation result.
249-
const nextQueryResult = (updater as MutationQueryReducer<any>)(
250-
currentQueryResult,
251-
{
252-
mutationResult: this.getResultWithDataState(result),
253-
queryName,
254-
queryVariables: variables!,
255-
}
256-
);
257-
258-
// Write the modified result back into the store if we got a new result.
259-
if (nextQueryResult) {
260-
cacheWrites.push({
261-
result: nextQueryResult,
262-
dataId: "ROOT_QUERY",
263-
query: document!,
264-
variables,
265-
});
245+
if (!complete || !currentQueryResult) {
246+
return;
247+
}
248+
249+
const updater = updateQueries[queryName];
250+
const { query: document, variables } = observableQuery;
251+
252+
// Run our reducer using the current query result and the mutation result.
253+
const nextQueryResult = (updater as MutationQueryReducer<any>)(
254+
currentQueryResult,
255+
{
256+
mutationResult: this.getResultWithDataState(result),
257+
queryName,
258+
queryVariables: variables!,
266259
}
260+
);
261+
262+
// Write the modified result back into the store if we got a new result.
263+
if (nextQueryResult) {
264+
cacheWrites.push({
265+
result: nextQueryResult,
266+
dataId: "ROOT_QUERY",
267+
query: document!,
268+
variables,
269+
});
267270
}
268271
});
269272

0 commit comments

Comments
 (0)