request<TData, TVars> method

  1. @override
Stream<OperationResponse<TData, TVars>> request<TData, TVars>(
  1. OperationRequest<TData, TVars> operationRequest, [
  2. NextTypedLink<TData, TVars>? forward
])
override

A function called when a request reaches this TypedLink

Implementation

@override
Stream<OperationResponse<TData, TVars>> request<TData, TVars>(
  OperationRequest<TData, TVars> operationRequest, [
  forward,
]) {
  try {
    return forward!(operationRequest).transform(
      StreamTransformer.fromHandlers(
        handleError: (error, stackTrace, sink) => sink.add(
          OperationResponse(
            operationRequest: operationRequest,
            linkException: error is LinkException
                ? error
                : TypedLinkException(error, stackTrace),
            dataSource: DataSource.None,
          ),
        ),
      ),
    );
  } catch (error, stackTrace) {
    return Stream.value(
      OperationResponse(
        operationRequest: operationRequest,
        linkException: error is LinkException
            ? error
            : TypedLinkException(error, stackTrace),
        dataSource: DataSource.None,
      ),
    );
  }
}