Skip to content

Commit

Permalink
Canonicalize empty result objects, too.
Browse files Browse the repository at this point in the history
Small addition to PR #7439.
  • Loading branch information
benjamn committed Jan 15, 2021
1 parent 2cb0944 commit 419e90a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/cache/inmemory/object-canon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ export class ObjectCanon {
// Arrays that contain the same elements in a different order can share
// the same SortedKeysInfo object, to save memory.
private keysByJSON = new Map<string, SortedKeysInfo>();

// This has to come last because it depends on keysByJSON.
public readonly empty = this.admit({});
}

type SortedKeysInfo = {
Expand Down
2 changes: 1 addition & 1 deletion src/cache/inmemory/readFromStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class StoreReader {
!context.policies.rootTypenamesById[objectOrReference.__ref] &&
!context.store.has(objectOrReference.__ref)) {
return {
result: {},
result: this.canon.empty,
missing: [missingFromInvariant(
new InvariantError(
`Dangling reference to missing ${objectOrReference.__ref} object`
Expand Down

0 comments on commit 419e90a

Please sign in to comment.