Type alias Exchange

Exchange: ((input) => ExchangeIO)

Type declaration

    • (input): ExchangeIO
    • Exchanges are both extensions for a Client and part of the control-flow executing Operations.


      Exchanges are responsible for the pipeline in urql that accepts Operations and returns OperationResults. They take care of adding functionality to a Client, like deduplication, caching, and fetching (i.e. making GraphQL requests).

      When passed to the Client, they're instantiated with the ExchangeInput object and return an ExchangeIO function, which is a mapping function that receives a stream of Operations and returns a stream of OperationResults.

      Like middleware, exchanges are composed, calling each other in a pipeline-like fashion, which is facilitated by exchanges calling forward, which is set to the next exchange's ExchangeIO function in the pipeline.



      import { pipe, onPush } from 'wonka';
      import { Exchange } from '@urql/core';

      const debugExchange: Exchange => {
      return ops$ => pipe(
      onPush(operation => console.log(operation)),
      onPush(result => console.log(result)),


      Returns ExchangeIO

Generated using TypeDoc