2020-07-28 23:09:34 +05:30
|
|
|
import { memoize } from 'lodash';
|
2020-03-13 15:44:24 +05:30
|
|
|
import createGqClient, { fetchPolicies } from '~/lib/graphql';
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
/**
|
|
|
|
* Returns a memoized client
|
|
|
|
*
|
|
|
|
* We defer creating the client so that importing this module does not cause any side-effects.
|
|
|
|
* Creating the client immediately caused issues with miragejs where the gql client uses the
|
|
|
|
* real fetch() instead of the shimmed one.
|
|
|
|
*/
|
|
|
|
const getClient = memoize(() =>
|
|
|
|
createGqClient(
|
|
|
|
{},
|
|
|
|
{
|
|
|
|
fetchPolicy: fetchPolicies.NO_CACHE,
|
|
|
|
},
|
|
|
|
),
|
2020-03-13 15:44:24 +05:30
|
|
|
);
|
2020-07-28 23:09:34 +05:30
|
|
|
|
|
|
|
export const query = (...args) => getClient().query(...args);
|