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,
]) =>
    link.request(operationRequest.execRequest).transform(
          StreamTransformer.fromHandlers(
            handleData: (response, sink) => sink.add(
              OperationResponse(
                operationRequest: operationRequest,
                data: (response.data == null || response.data!.isEmpty)
                    ? null
                    : operationRequest.parseData(response.data!),
                extensions:
                    response.context.entry<ResponseExtensions>()?.extensions,
                graphqlErrors: response.errors,
                dataSource: DataSource.Link,
              ),
            ),
            handleError: (error, stackTrace, sink) => sink.add(
              OperationResponse(
                operationRequest: operationRequest,
                linkException: error is LinkException
                    ? error
                    : ServerException(
                        originalException: error,
                        parsedResponse: null,
                      ),
                dataSource: DataSource.Link,
              ),
            ),
          ),
        );