Skip to content

fix: useExisting - #51

Merged
LounisBou merged 5 commits into
mainfrom
fix-use-existing
Feb 10, 2026
Merged

LounisBou merged 5 commits into
mainfrom
fix-use-existing

Conversation

@LounisBou

@LounisBou LounisBou commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

Related PR:

What's the problem:

getRelation in src/hydra/hydra-plugin.js have useExisting option. This option is meant to say "don't use cached data" if set to false — but it actually returns older data because it skips the store (which has fresh updates) and falls into the embedded object factory (which has stale data from the PATCH response).

What's the solution:

The embedded object path should not be reached when useExisting: false — we should bypass existing data, not to use an even older source. So when useExisting: false and the input is an object, it should fall through to getItem which resolves by IRI. That's what this PR do !

@LounisBou
LounisBou requested a review from misaert February 10, 2026 10:39
Comment thread src/hydra/hydra-plugin.js Outdated
}

if ('object' === typeof itemOrIri && false === (options.force ?? false)) {
if ('object' === typeof itemOrIri && false === (options.force ?? false) && false !== (options.useExisting ?? true)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See together, use a constant with the previous if to keep the same condition for useExisting. Like you say, it is better to use false !== (options.useExisting ?? true) to prevent wrong value other than boolean.

@LounisBou
LounisBou merged commit 87117c4 into main Feb 10, 2026
1 of 2 checks passed
@LounisBou
LounisBou deleted the fix-use-existing branch February 10, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants