Skip to content

Commit

Permalink
Remove hasResults check
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Mar 14, 2023
1 parent 7d0f741 commit 8a39fd6
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions packages/core/src/internal/fetchSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ async function* fetchOperation(
fetchOptions: RequestInit
) {
let abortController: AbortController | void;
let result: OperationResult | null = null;
let response: Response;
let hasResults = false;

try {
if (typeof AbortController !== 'undefined') {
Expand All @@ -61,9 +61,7 @@ async function* fetchOperation(

let buffer = '';
let isPreamble = true;
let result: OperationResult | null = null;
chunks: for await (const data of iterator) {
hasResults = true;
buffer += toString(data);

let boundaryIndex: number;
Expand All @@ -88,7 +86,8 @@ async function* fetchOperation(
} catch (_error) {}

if (next.startsWith('--') || (payload && !payload.hasNext)) {
if (!result) yield makeResult(operation, {}, response);
if (!result)
yield (result = makeResult(operation, {}, response));
break chunks;
}
}
Expand All @@ -97,7 +96,7 @@ async function* fetchOperation(
}
}
} catch (error: any) {
if (hasResults) {
if (result) {
throw error;
}

Expand Down

0 comments on commit 8a39fd6

Please sign in to comment.