How to use the react-relay-network-modern/es.cacheMiddleware function in react-relay-network-modern

To help you get started, we’ve selected a few react-relay-network-modern examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coralproject / talk / src / core / client / framework / lib / network / createNetwork.ts View on Github external
export default function createNetwork(
  subscriptionClient: ManagedSubscriptionClient,
  tokenGetter: TokenGetter,
  clientID: string
) {
  return new RelayNetworkLayer(
    [
      customErrorMiddleware,
      cacheMiddleware({
        size: 100, // max 100 requests
        ttl: 900000, // 15 minutes
        clearOnMutation: true,
      }),
      urlMiddleware({
        url: () => Promise.resolve(graphqlURL),
      }),
      retryMiddleware({
        fetchTimeout: 15000,
        retryDelays: (attempt: number) => Math.pow(2, attempt + 4) * 100,
        // or simple array [3200, 6400, 12800, 25600, 51200, 102400, 204800, 409600],
        statusCodes: [500, 503, 504],
        beforeRetry: ({ abort, attempt }) => {
          if (attempt > 2) {
            abort();
          }