Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resolveNestedRelations disabling during StoryblokClient init #844

Open
edvinasjurele opened this issue Jul 26, 2024 · 3 comments
Open
Assignees
Labels
has-workaround [Issue] Temporary solutions available. p4-important [Priority] Violate documented behavior or significantly improve performance (priority)

Comments

@edvinasjurele
Copy link

Expected Behavior

Storyblok client is possible to initialize with resolveNestedRelations disabled.

Current Behavior

Initializing the Storyblok client with resolveNestedRelations flag disabled, does not correctly set the initial value

const Storyblok = new StoryblokClient({
  accessToken: '<TOKEN>',
  resolveNestedRelations: false,
});

Temporary workaround

Manually set flag AFTER the storyblok client initialization.

Storyblok.resolveNestedRelations = false;

Steps to Reproduce

https://runkit.com/embed/xx23fbgocz7c

Screenshot 2024-07-26 at 15 27 02

Potential defect

When passing resolveNestedRelations: false, as part of init object, the resolveNestedRelations should be set to false, but due to this.resolveNestedRelations = config.resolveNestedRelations || true in the

this.resolveNestedRelations = config.resolveNestedRelations || true
it is set to true for all falsey values including FALSE itself, as "false || true => true".

We might replace || with ??

image
@alvarosabu alvarosabu added p4-important [Priority] Violate documented behavior or significantly improve performance (priority) has-workaround [Issue] Temporary solutions available. labels Sep 6, 2024
@alvarosabu
Copy link
Contributor

Hi @edvinasjurele thanks for opening this issue. I think I understand the issue, I tried to open the reproduction tho and it's broken (gives me an error) could you please add a working reproduction please?

@alvarosabu alvarosabu added the needs-reproduction [Contribution] The issue requires minimal reproduction. label Sep 6, 2024
@alvarosabu alvarosabu self-assigned this Sep 6, 2024
@edvinasjurele
Copy link
Author

Hi @alvarosabu, hm, the repro link works fine for me 🤔 but here is another repro: https://stackblitz.com/edit/stackblitz-starters-5wkmv5?file=index.js

@alvarosabu
Copy link
Contributor

Hi @edvinasjurele thanks for providing another reproduction, I dont know what happened but I also managed to run the first one, I like the runkit is really helpful.

Let me take care of it.

@alvarosabu alvarosabu removed the needs-reproduction [Contribution] The issue requires minimal reproduction. label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-workaround [Issue] Temporary solutions available. p4-important [Priority] Violate documented behavior or significantly improve performance (priority)
Projects
None yet
Development

No branches or pull requests

2 participants