diff --git a/src/cache/inmemory/__tests__/entityStore.ts b/src/cache/inmemory/__tests__/entityStore.ts index 75130b44a06..0cc51a1f411 100644 --- a/src/cache/inmemory/__tests__/entityStore.ts +++ b/src/cache/inmemory/__tests__/entityStore.ts @@ -1555,11 +1555,11 @@ describe('EntityStore', () => { expect(() => cache.readQuery({ query: queryWithAliases, - })).toThrow(/Dangling reference to missing ABCs:.* object/); + })).toThrow(/Can't find field 'a' on ABCs:.* object/); expect(() => cache.readQuery({ query: queryWithoutAliases, - })).toThrow(/Dangling reference to missing ABCs:.* object/); + })).toThrow(/Can't find field 'a' on ABCs:.* object/); }); it("gracefully handles eviction amid optimistic updates", () => { @@ -1639,8 +1639,8 @@ describe('EntityStore', () => { const missing = [ new MissingFieldError( - "Dangling reference to missing Author:2 object", - ["book", "author"], + "Can't find field 'name' on Author:2 object", + ["book", "author", "name"], expect.anything(), expect.anything(), ), diff --git a/src/cache/inmemory/__tests__/policies.ts b/src/cache/inmemory/__tests__/policies.ts index c2a7b7b8c2f..156b5a5ea8a 100644 --- a/src/cache/inmemory/__tests__/policies.ts +++ b/src/cache/inmemory/__tests__/policies.ts @@ -2397,7 +2397,7 @@ describe("type policies", function () { }); expect(read).toThrow( - /Dangling reference to missing Book:{"isbn":"156858217X"} object/ + /Can't find field 'title' on Book:{"isbn":"156858217X"} object/ ); const stealThisData = { @@ -2529,11 +2529,11 @@ describe("type policies", function () { }); expect(() => read("0393354326")).toThrow( - /Dangling reference to missing Book:{"isbn":"0393354326"} object/ + /Can't find field 'title' on Book:{"isbn":"0393354326"} object/ ); expect(() => read("156858217X")).toThrow( - /Dangling reference to missing Book:{"isbn":"156858217X"} object/ + /Can't find field 'title' on Book:{"isbn":"156858217X"} object/ ); }); diff --git a/src/cache/inmemory/readFromStore.ts b/src/cache/inmemory/readFromStore.ts index 5951ee9a580..b02e507f2c8 100644 --- a/src/cache/inmemory/readFromStore.ts +++ b/src/cache/inmemory/readFromStore.ts @@ -213,20 +213,6 @@ export class StoreReader { objectOrReference, context, }: ExecSelectionSetOptions): ExecResult { - if (isReference(objectOrReference) && - !context.policies.rootTypenamesById[objectOrReference.__ref] && - !context.store.has(objectOrReference.__ref)) { - return { - result: {}, - missing: [missingFromInvariant( - new InvariantError( - `Dangling reference to missing ${objectOrReference.__ref} object` - ), - context, - )], - }; - } - const { fragmentMap, variables, policies, store } = context; const objectsToMerge: { [key: string]: any }[] = []; const finalResult: ExecResult = { result: null };