Skip to content

Commit

Permalink
Avoid empty string as possible toReference return type.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed May 29, 2020
1 parent 597dc87 commit 4b1fe83
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/cache/inmemory/entityStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,13 +344,15 @@ export abstract class EntityStore implements NormalizedCache {
public toReference = (
object: StoreObject,
mergeIntoStore?: boolean,
) => {
): Reference | undefined => {
const [id] = this.policies.identify(object);
const ref = id && makeReference(id);
if (ref && mergeIntoStore) {
this.merge(id!, object);
if (id) {
const ref = makeReference(id);
if (mergeIntoStore) {
this.merge(id, object);
}
return ref;
}
return ref;
}
}

Expand Down

0 comments on commit 4b1fe83

Please sign in to comment.