diff --git a/exchanges/graphcache/src/store/data.test.ts b/exchanges/graphcache/src/store/data.test.ts index db75fbadb8..35ed1edb2a 100644 --- a/exchanges/graphcache/src/store/data.test.ts +++ b/exchanges/graphcache/src/store/data.test.ts @@ -406,4 +406,21 @@ describe('commutative changes', () => { InMemoryData.initDataState(data, null); expect(InMemoryData.readRecord('Query', 'index')).toBe(2); }); + + it('prevents inspectFields from failing for uninitialised layers', () => { + InMemoryData.initDataState(data, null); + InMemoryData.writeRecord('Query', 'test', true); + InMemoryData.clearDataState(); + + InMemoryData.reserveLayer(data, 1); + + InMemoryData.initDataState(data, null); + expect(InMemoryData.inspectFields('Query')).toEqual([ + { + arguments: null, + fieldKey: 'test', + fieldName: 'test', + }, + ]); + }); });