Skip to content

Commit

Permalink
Move stringifyForDisplay to utilities/common rather than /testing.
Browse files Browse the repository at this point in the history
Fixing a regression introduced by #8508.

Importing from @apollo/client/testing in cache/inmemory/policies.ts made
Rollup display circular dependency warnings (which are often harmless
but also worth avoiding) and resulted in importing React-related code
even when using @apollo/client/core rather than @apollo/client, which is
a more serious problem.
  • Loading branch information
benjamn committed Jul 23, 2021
1 parent 9ab9400 commit 60db4e4
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/__tests__/__snapshots__/exports.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ Array [
"itAsync",
"mockObservableLink",
"mockSingleLink",
"stringifyForDisplay",
"stripSymbols",
"subscribeAndCount",
"withErrorSpy",
Expand Down Expand Up @@ -377,6 +376,7 @@ Array [
"resultKeyNameFromField",
"shouldInclude",
"storeKeyNameFromField",
"stringifyForDisplay",
"valueToObjectRepresentation",
]
`;
3 changes: 2 additions & 1 deletion src/cache/inmemory/policies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
getStoreKeyName,
canUseWeakMap,
isNonNullObject,
stringifyForDisplay,
} from '../../utilities';
import {
IdGetter,
Expand Down Expand Up @@ -52,7 +53,7 @@ import { WriteContext } from './writeToStore';
// used by getStoreKeyName. This function is used when computing storeFieldName
// strings (when no keyArgs has been configured for a field).
import { canonicalStringify } from './object-canon';
import { stringifyForDisplay } from '../../testing';

getStoreKeyName.setStringify(canonicalStringify);

export type TypePolicies = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { makeUniqueId } from "../common/makeUniqueId";
import { makeUniqueId } from "./makeUniqueId";

export function stringifyForDisplay(value: any): string {
const undefId = makeUniqueId("stringifyForDisplay");
Expand Down
1 change: 1 addition & 0 deletions src/utilities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@ export * from './common/errorHandling';
export * from './common/canUse';
export * from './common/compact';
export * from './common/makeUniqueId';
export * from './common/stringifyForDisplay';

export * from './types/IsStrictlyAny';
1 change: 0 additions & 1 deletion src/utilities/testing/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ export { stripSymbols } from './stripSymbols';
export { default as subscribeAndCount } from './subscribeAndCount';
export { itAsync } from './itAsync';
export * from './withConsoleSpy';
export * from './stringifyForDisplay';
5 changes: 1 addition & 4 deletions src/utilities/testing/mocking/mockLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ import {
removeClientSetsFromDocument,
removeConnectionDirectiveFromDocument,
cloneDeep,
} from '../../../utilities';

import {
stringifyForDisplay,
} from '../../../testing';
} from '../../../utilities';

export type ResultFunction<T> = () => T;

Expand Down

0 comments on commit 60db4e4

Please sign in to comment.