Skip to content

Commit

Permalink
Export Reference-related utilities from @apollo/client.
Browse files Browse the repository at this point in the history
When writing custom read and merge functions, it's useful to be able to
annotate the existing and incoming parameters with the Reference type,
rather than relying on the toReference and isReference helpers.
  • Loading branch information
benjamn committed Jan 15, 2020
1 parent ce3fe00 commit 451a22f
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/ApolloClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import gql from 'graphql-tag';

import { Observable } from '../utilities/observables/Observable';
import { makeReference } from '../utilities/graphql/storeUtils';
import { makeReference } from '../core';
import { ApolloLink } from '../link/core/ApolloLink';
import { HttpLink } from '../link/http/HttpLink';
import { InMemoryCache } from '../cache/inmemory/inMemoryCache';
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/optimistic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { MutationQueryReducersMap } from '../core/types';
import { Subscription } from '../utilities/observables/Observable';
import { ApolloClient } from '../';
import { addTypenameToDocument } from '../utilities/graphql/transform';
import { makeReference } from '../utilities/graphql/storeUtils';
import { makeReference } from '../core';
import { stripSymbols } from '../utilities/testing/stripSymbols';
import { itAsync } from '../utilities/testing/itAsync';
import { InMemoryCache } from '../cache/inmemory/inMemoryCache';
Expand Down
2 changes: 1 addition & 1 deletion src/cache/inmemory/__tests__/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import gql, { disableFragmentWarnings } from 'graphql-tag';

import { stripSymbols } from '../../../utilities/testing/stripSymbols';
import { cloneDeep } from '../../../utilities/common/cloneDeep';
import { makeReference } from '../../../utilities/graphql/storeUtils';
import { makeReference } from '../../../core';
import { InMemoryCache, InMemoryCacheConfig } from '../inMemoryCache';

disableFragmentWarnings();
Expand Down
2 changes: 1 addition & 1 deletion src/cache/inmemory/__tests__/diffAgainstStore.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import gql, { disableFragmentWarnings } from 'graphql-tag';

import { Reference, makeReference } from '../../../utilities/graphql/storeUtils';
import { Reference, makeReference } from '../../../core';
import { defaultNormalizedCacheFactory } from '../entityStore';
import { StoreReader } from '../readFromStore';
import { StoreWriter } from '../writeToStore';
Expand Down
2 changes: 1 addition & 1 deletion src/cache/inmemory/__tests__/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import gql from "graphql-tag";
import { InMemoryCache } from "../inMemoryCache";
import { StoreValue } from "../../../utilities";
import { FieldPolicy, Policies } from "../policies";
import { Reference } from "../../../utilities/graphql/storeUtils";
import { Reference } from "../../../core";

function reverse(s: string) {
return s.split("").reverse().join("");
Expand Down
2 changes: 1 addition & 1 deletion src/cache/inmemory/__tests__/readFromStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import gql from 'graphql-tag';
import { stripSymbols } from '../../../utilities/testing/stripSymbols';
import { StoreObject } from '../types';
import { StoreReader } from '../readFromStore';
import { makeReference } from '../../../utilities/graphql/storeUtils';
import { makeReference } from '../../../core';
import { defaultNormalizedCacheFactory } from '../entityStore';
import { withError } from './diffAgainstStore';
import { Policies } from '../policies';
Expand Down
2 changes: 1 addition & 1 deletion src/core/__tests__/QueryManager/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { MockSubscriptionLink } from '../../../utilities/testing/mocking/mockSub

// core
import { QueryManager } from '../../QueryManager';
import { Reference } from '../../../utilities/graphql/storeUtils';
import { Reference } from '../../../core';

describe('Link interactions', () => {
it('includes the cache on the context for eviction links', done => {
Expand Down
5 changes: 5 additions & 0 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ export { ServerError, throwServerError } from '../link/utils/throwServerError';

export { Observable } from '../utilities/observables/Observable';
export { getMainDefinition } from '../utilities/graphql/getFromAST';
export {
Reference,
isReference,
makeReference,
} from '../utilities/graphql/storeUtils';

/* Supporting */

Expand Down

0 comments on commit 451a22f

Please sign in to comment.