How to use the react-relay-network-modern/node8.loggerMiddleware 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 artsy / reaction / src / Artsy / Relay / createRelaySSREnvironment.ts View on Github external
},
      }),

      // TODO: This has been moved over from `Utils/metaphysics` but can eventually
      // be replaced by error / retry middleware
      next => async req => {
        const response = await next(req)
        if (!checkStatus || (response.status >= 200 && response.status < 300)) {
          return response
        } else {
          const error = new NetworkError(response.statusText)
          error.response = response
          throw error
        }
      },
      loggingEnabled && loggerMiddleware(),
      loggingEnabled && metaphysicsExtensionsLoggerMiddleware(),
      loggingEnabled && errorMiddleware({ disableServerMiddlewareTip: true }),
    ])

  const source = new RecordSource()
  const store = new Store(source)

  const environment = new Environment({
    network,
    store,
  }) as RelaySSREnvironment

  environment.relaySSRMiddleware = relaySSRMiddleware

  return environment
}
github artsy / emission / src / lib / relay / createEnvironment.ts View on Github external
export default function createEnvironment() {
  const network = new RelayNetworkLayer([
    cacheMiddleware(),
    urlMiddleware({
      url: metaphysicsURL,
      headers: {
        "Content-Type": "application/json",
        "User-Agent": Emission.userAgent,
        "X-USER-ID": Emission.userID,
        "X-ACCESS-TOKEN": Emission.authenticationToken,
        "X-TIMEZONE": Constants.LocalTimeZone,
      },
    }),
    loggerMiddleware(),
    errorMiddleware({
      disableServerMiddlewareTip: true,
    }),
    metaphysicsExtensionsLoggerMiddleware(),
    timingMiddleware(),
  ])

  const source = new RecordSource()
  const store = new Store(source)
  return new Environment({
    network,
    store,
  })
}