From fdcc2d0f6453c4f7b6d6c49fa8b5dbaef096f015 Mon Sep 17 00:00:00 2001 From: Phil Pluckthun Date: Mon, 9 Sep 2019 14:19:51 +0100 Subject: [PATCH] Fix user keying function returning null --- src/store.test.ts | 2 ++ src/store.ts | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) 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) {