Skip to content
This repository has been archived by the owner on Jul 6, 2020. It is now read-only.

Commit

Permalink
Fix user keying function returning null (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten authored and JoviDeCroock committed Sep 9, 2019
1 parent bdf3df6 commit 0505eac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0505eac

Please sign in to comment.