Skip to content

Commit 68f53fc

Browse files
committed
pare down receiver algorithm
1 parent 5c49d11 commit 68f53fc

1 file changed

Lines changed: 0 additions & 90 deletions

File tree

packages/delegate/src/InitialReceiver.ts

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@ export class InitialReceiver implements Receiver {
3030
private readonly asyncSelectionSets: Record<string, SelectionSetNode>;
3131
private readonly resultTransformer: (originalResult: ExecutionResult) => any;
3232
private readonly initialResultDepth: number;
33-
private deferredPatches: Record<string, Array<ExecutionPatchResult>>;
34-
private streamedPatches: Record<string, Record<number, Array<ExecutionPatchResult>>>;
3533
private cache: ExpectantStore<MergedExecutionResult>;
3634
private stoppers: Array<Stop>;
3735
private loaders: Record<string, DataLoader<GraphQLResolveInfo, any>>;
38-
private infos: Record<string, Record<string, GraphQLResolveInfo>>;
3936

4037
constructor(
4138
asyncIterable: AsyncIterable<AsyncExecutionResult>,
@@ -53,12 +50,9 @@ export class InitialReceiver implements Receiver {
5350
this.resultTransformer = resultTransformer;
5451
this.initialResultDepth = info ? responsePathAsArray(info.path).length - 1 : 0;
5552

56-
this.deferredPatches = Object.create(null);
57-
this.streamedPatches = Object.create(null);
5853
this.cache = new ExpectantStore();
5954
this.stoppers = [];
6055
this.loaders = Object.create(null);
61-
this.infos = Object.create(null);
6256
}
6357

6458
public async getInitialResult(): Promise<MergedExecutionResult> {
@@ -132,16 +126,6 @@ export class InitialReceiver implements Receiver {
132126
fieldNodes: [].concat(...infos.map(info => info.fieldNodes)),
133127
};
134128

135-
let infosByParentKey = this.infos[parentKey];
136-
if (infosByParentKey === undefined) {
137-
infosByParentKey = this.infos[parentKey] = Object.create(null);
138-
}
139-
140-
if (infosByParentKey[responseKey] === undefined) {
141-
infosByParentKey[responseKey] = combinedInfo;
142-
this.onNewInfo(pathKey);
143-
}
144-
145129
const parent = this.cache.get(parentKey);
146130

147131
if (parent === undefined) {
@@ -228,24 +212,6 @@ export class InitialReceiver implements Receiver {
228212
const responseKey = parentPath.pop();
229213
const parentPathKey = parentPath.join('.');
230214
const pathKey = `${parentPathKey}.${responseKey}`;
231-
const info = this.infos[parentPathKey]?.[responseKey];
232-
if (info === undefined) {
233-
const streamedPatches = this.streamedPatches[pathKey];
234-
if (streamedPatches === undefined) {
235-
this.streamedPatches[pathKey] = { [index]: [transformedResult] };
236-
continue;
237-
}
238-
239-
const indexPatches = streamedPatches[index];
240-
if (indexPatches === undefined) {
241-
streamedPatches[index] = [transformedResult];
242-
continue;
243-
}
244-
245-
indexPatches.push(transformedResult);
246-
continue;
247-
}
248-
249215
const { onLocatedError } = this.delegationContext;
250216
const newResult = mergeDataAndErrors(transformedResult.data, transformedResult.errors, onLocatedError);
251217

@@ -257,17 +223,6 @@ export class InitialReceiver implements Receiver {
257223
const responseKey = parentPath.pop();
258224
const parentPathKey = parentPath.join('.');
259225
const pathKey = `${parentPathKey}.${responseKey}`;
260-
const info = this.infos[parentPathKey]?.[responseKey];
261-
if (info === undefined) {
262-
const deferredPatches = this.deferredPatches[pathKey];
263-
if (deferredPatches === undefined) {
264-
this.deferredPatches[pathKey] = [transformedResult];
265-
continue;
266-
}
267-
268-
deferredPatches.push(transformedResult);
269-
continue;
270-
}
271226

272227
const { onLocatedError } = this.delegationContext;
273228
const newResult = mergeDataAndErrors(transformedResult.data, transformedResult.errors, onLocatedError);
@@ -294,51 +249,6 @@ export class InitialReceiver implements Receiver {
294249
);
295250

296251
this.cache.set(pathKey, mergedResult);
297-
298-
const infosByParentKey = this.infos[pathKey];
299-
if (infosByParentKey !== undefined) {
300-
const unpathedErrors = newResult.unpathedErrors;
301-
Object.keys(infosByParentKey).forEach(responseKey => {
302-
const info = infosByParentKey[responseKey];
303-
const data = newResult.data[responseKey];
304-
if (data !== undefined) {
305-
const subResult = { data, unpathedErrors };
306-
const subPathKey = `${pathKey}.${responseKey}`;
307-
this.onNewResult(
308-
subPathKey,
309-
subResult,
310-
isCompositeType(getNamedType(info.returnType))
311-
? {
312-
kind: Kind.SELECTION_SET,
313-
selections: [].concat(...info.fieldNodes.map(fieldNode => fieldNode.selectionSet.selections)),
314-
}
315-
: undefined
316-
);
317-
}
318-
});
319-
}
320-
}
321-
322-
private onNewInfo(pathKey: string): void {
323-
const deferredPatches = this.deferredPatches[pathKey];
324-
if (deferredPatches !== undefined) {
325-
deferredPatches.forEach(deferredPatch => {
326-
const { onLocatedError } = this.delegationContext;
327-
const newResult = mergeDataAndErrors(deferredPatch.data, deferredPatch.errors, onLocatedError);
328-
this.onNewResult(pathKey, newResult, this.asyncSelectionSets[deferredPatch.label]);
329-
});
330-
}
331-
332-
const streamedPatches = this.streamedPatches[pathKey];
333-
if (streamedPatches !== undefined) {
334-
Object.entries(streamedPatches).forEach(([index, indexPatches]) => {
335-
indexPatches.forEach(patch => {
336-
const { onLocatedError } = this.delegationContext;
337-
const newResult = mergeDataAndErrors(patch.data, patch.errors, onLocatedError);
338-
this.onNewResult(`${pathKey}.${index}`, newResult, this.asyncSelectionSets[patch.label]);
339-
});
340-
});
341-
}
342252
}
343253
}
344254

0 commit comments

Comments
 (0)