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 initUrqlClient(initialState) {
// Create a new client for every server-side rendered request to reset its state
// for each rendered page
// Reuse the client on the client-side however
const isServer = typeof window === 'undefined';
if (isServer || !urqlClient) {
ssrCache = ssrExchange({ initialState });
urqlClient = createClient({
url: 'https://api.graph.cool/simple/v1/cixmkt2ul01q00122mksg82pn',
// Active suspense mode on the server-side
suspense: isServer,
exchanges: [dedupExchange, cacheExchange, ssrCache, fetchExchange],
});
}
// Return both the cache and the client
return [urqlClient, ssrCache];
}
module.exports = function initUrqlClient(initialState, { url }) {
// Create a new client for every server-side rendered request to reset its state
// for each rendered page
// Reuse the client on the client-side however
const isServer = typeof window === 'undefined';
if (isServer || !urqlClient) {
ssrCache = ssrExchange({ initialState });
urqlClient = createClient({
url,
// Active suspense mode on the server-side
suspense: isServer,
exchanges: [dedupExchange, cacheExchange, ssrCache, fetchExchange]
});
}
// Return both the cache and the client
return [urqlClient, ssrCache];
};