Skip to content

Commit a66eed2

Browse files
committed
simplify
1 parent 68f53fc commit a66eed2

1 file changed

Lines changed: 6 additions & 33 deletions

File tree

packages/delegate/src/InitialReceiver.ts

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -194,40 +194,13 @@ export class InitialReceiver implements Receiver {
194194

195195
const transformedResult = this.resultTransformer(asyncResult);
196196

197-
if (path.length === 1) {
198-
const pathKey = path.join('.');
197+
const newResult = mergeDataAndErrors(
198+
transformedResult.data,
199+
transformedResult.errors,
200+
this.delegationContext.onLocatedError
201+
);
199202

200-
const { onLocatedError } = this.delegationContext;
201-
const newResult = mergeDataAndErrors(transformedResult.data, transformedResult.errors, onLocatedError);
202-
203-
this.onNewResult(pathKey, newResult, this.asyncSelectionSets[asyncResult.label]);
204-
continue;
205-
}
206-
207-
const lastPathSegment = path[path.length - 1];
208-
const isStreamPatch = typeof lastPathSegment === 'number';
209-
if (isStreamPatch) {
210-
const parentPath = path.slice();
211-
const index = parentPath.pop();
212-
const responseKey = parentPath.pop();
213-
const parentPathKey = parentPath.join('.');
214-
const pathKey = `${parentPathKey}.${responseKey}`;
215-
const { onLocatedError } = this.delegationContext;
216-
const newResult = mergeDataAndErrors(transformedResult.data, transformedResult.errors, onLocatedError);
217-
218-
this.onNewResult(`${pathKey}.${index}`, newResult, this.asyncSelectionSets[asyncResult.label]);
219-
continue;
220-
}
221-
222-
const parentPath = path.slice();
223-
const responseKey = parentPath.pop();
224-
const parentPathKey = parentPath.join('.');
225-
const pathKey = `${parentPathKey}.${responseKey}`;
226-
227-
const { onLocatedError } = this.delegationContext;
228-
const newResult = mergeDataAndErrors(transformedResult.data, transformedResult.errors, onLocatedError);
229-
230-
this.onNewResult(pathKey, newResult, this.asyncSelectionSets[asyncResult.label]);
203+
this.onNewResult(path.join('.'), newResult, this.asyncSelectionSets[asyncResult.label]);
231204
}
232205

233206
setTimeout(() => {

0 commit comments

Comments
 (0)