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 b1aa7ee commit a1ddb49
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 @@ -62,9 +62,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 @@ -89,7 +87,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 @@ -98,7 +97,7 @@ async function* fetchOperation(
}
}
} catch (error: any) {
if (hasResults) {
if (result) {
throw error;
}

Expand Down

0 comments on commit a1ddb49

Please sign in to comment.