diff --git a/src/store.test.ts b/src/store.test.ts index 64bfbe2..a309550 100644 --- a/src/store.test.ts +++ b/src/store.test.ts @@ -41,6 +41,7 @@ describe('Store with KeyingConfig', () => { it('generates keys from custom keying function', () => { const store = new Store(undefined, undefined, undefined, undefined, { User: () => 'me', + None: () => null, }); expect(store.keyOfEntity({ __typename: 'Any', id: '123' })).toBe('Any:123'); @@ -49,6 +50,7 @@ describe('Store with KeyingConfig', () => { ); expect(store.keyOfEntity({ __typename: 'Any' })).toBe(null); expect(store.keyOfEntity({ __typename: 'User' })).toBe('User:me'); + expect(store.keyOfEntity({ __typename: 'None' })).toBe(null); }); }); diff --git a/src/store.ts b/src/store.ts index 792a3d5..d35d172 100644 --- a/src/store.ts +++ b/src/store.ts @@ -157,7 +157,7 @@ export class Store { let key; if (this.keys[typename]) { - key = `${this.keys[typename](data)}`; + key = this.keys[typename](data); } else if (id !== undefined && id !== null) { key = `${id}`; } else if (_id !== undefined && _id !== null) {