Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (req.id === "SearchBarSuggestQuery" && req.variables.term === "")
return Promise.resolve({ data: { viewer: {} } })
return next(req)
},
urlMiddleware({
url: METAPHYSICS_ENDPOINT,
headers: !!user
? {
...headers,
"X-USER-ID": user && user.id,
"X-ACCESS-TOKEN": user && user.accessToken,
}
: headers,
}),
relaySSRMiddleware.getMiddleware(),
cacheMiddleware({
size: 100, // max 100 requests
ttl: 900000, // 15 minutes
onInit: queryResponseCache => {
if (!isServer) {
hydrateCacheFromSSR(queryResponseCache)
}
},
}),
// 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 {