Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
}
},
}),
authMiddleware({
token: tokenGetter,
}),