2020-07-09 12:08:56 +00:00
|
|
|
import { memoize } from 'lodash';
|
2020-02-14 15:09:08 +00:00
|
|
|
import createGqClient, { fetchPolicies } from '~/lib/graphql';
|
|
|
|
|
2020-07-09 12:08:56 +00:00
|
|
|
/**
|
|
|
|
* 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-02-14 15:09:08 +00:00
|
|
|
);
|
2020-07-09 12:08:56 +00:00
|
|
|
|
|
|
|
export const query = (...args) => getClient().query(...args);
|