Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
executeRequestOperation(operation: Operation): Source {
const { key, operationName } = operation;
const operationResults$ = pipe(
this.results$,
filter(res => res.operation.key === key)
);
if (operationName === 'mutation') {
// A mutation is always limited to just a single result and is never shared
return pipe(
operationResults$,
onStart(() => this.dispatchOperation(operation)),
take(1)
);
}
const teardown$ = pipe(
this.operations$,
filter(op => op.operationName === 'teardown' && op.key === key)
);
const result$ = pipe(
operationResults$,
takeUntil(teardown$),
onStart(() => this.onOperationStart(operation)),
onEnd(() => this.onOperationEnd(operation))
);
return pipe(
operationResults$,
onStart(() => this.dispatchOperation(operation)),
take(1)
);
}
const teardown$ = pipe(
this.operations$,
filter(op => op.operationName === 'teardown' && op.key === key)
);
const result$ = pipe(
operationResults$,
takeUntil(teardown$),
onStart(() => this.onOperationStart(operation)),
onEnd(() => this.onOperationEnd(operation))
);
return operation.context.suspense !== false &&
this.suspense &&
operationName === 'query'
? toSuspenseSource(result$)
: result$;
}