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

Possibility to opt-out from rels inlining in StoryblokClient.get() #839

Open
edvinasjurele opened this issue Jul 18, 2024 · 0 comments
Open
Labels
has-workaround [Issue] Temporary solutions available. pending-triage [Issue] Ticket is pending to be prioritised

Comments

@edvinasjurele
Copy link

Context

We are using Redis on our end to save fetch request times and have data as close to the app as possible. However, there is one functionality StoryblokClient provides, which is rels inlining, when the resolve_relations option is used.

FYI, we are using storyblok/astro, and when passing resolve_relations it does 2 things with the same flag:

  • Enables Content Delivery API to enrich story with resolved relations under rels: [{...}]
  • Instructs StoryblokClient to process story and inline relations from the array to actual usages (by uuid) in the story contents.

Problem

For bigger pages, we have huge (~10MB+) story json objects returned from StoryblokClient.get(…), caused by relations inserting to the object, which is not possible to opt-out. However, we still need to pass resolve_relations which would instruct Content Delivery API to resolve them and return via rels:[{...}] array (this is very useful, as using client all fetching content comes out-of-the-box, and need for direct link building and fetching).

We have estimated that if StoryblokClient would not inline those relations it would be only 500kb story json which we cache and do the inlining ourselves after we get story from Redis cache. That would be ideal!! Adding a diagram to showcase our business case.

64b79684-aa5b-46c2-a456-0543f0428993

This implies a couple of following ways to think of:

  • Either allow users to opt-out from inlining bit (possibly for links also? not sure), so they can do the rels inlining themselves
  • Allow Redis cache integration to the client, to be squeezed in AFTER content delivery fetching, but BEFORE inlining rels and bloating stories, leaving the latter as the last bit and uncachable (or could be configurable for better granular control)

Temporary workaround

In cases when we have resolve_relations we are doing the following branched-out logic specifically:

  1. Fetch Content Delivery API directly
  2. Add response to Redis cache
  3. Before returning the story (in-app getStory util abstraction), execute custom logic to inline relations into it to have a finalized story for rendering.

Though looking into what is recommended in Reducing the size of the response it only refers to Content Deliver API, hence our problem is that Storyblok Client also reacts to resolve_relations and does the inlining part why do not need.

Unfortunately, we cannot use the StoryblokClient for such cases due to missing opt-out functionality. Or maybe there are other ways to solve the issue we are not aware of?

@alvarosabu alvarosabu added pending-triage [Issue] Ticket is pending to be prioritised has-workaround [Issue] Temporary solutions available. labels Sep 6, 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. pending-triage [Issue] Ticket is pending to be prioritised
Projects
None yet
Development

No branches or pull requests

2 participants