Skip to content

Commit

Permalink
Force hasNext: false early if a non-incremental additive-result has…
Browse files Browse the repository at this point in the history
… errored
  • Loading branch information
kitten committed Jul 4, 2024
1 parent 61c0e6e commit d2ac588
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/core/src/utils/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export const mergeResultPatch = (
}

const withData = { data: prevResult.data };
let hasNext =
nextResult.hasNext != null ? nextResult.hasNext : prevResult.hasNext;
if (incremental) {
for (const patch of incremental) {
if (Array.isArray(patch.errors)) {
Expand Down Expand Up @@ -155,6 +157,9 @@ export const mergeResultPatch = (
(nextResult.errors as any[]) ||
(nextResult.payload && nextResult.payload.errors) ||
errors;
if (hasNext && errors.length && !nextResult.data) {
hasNext = false;
}
}

return {
Expand All @@ -164,8 +169,7 @@ export const mergeResultPatch = (
? new CombinedError({ graphQLErrors: errors, response })
: undefined,
extensions: hasExtensions ? extensions : undefined,
hasNext:
nextResult.hasNext != null ? nextResult.hasNext : prevResult.hasNext,
hasNext,
stale: false,
};
};
Expand Down

0 comments on commit d2ac588

Please sign in to comment.