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

Fix user keying function returning null #68

Merged
merged 1 commit into from
Sep 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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