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

Feature/resolve relations support #28

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

boldbart
Copy link
Contributor

@boldbart boldbart commented Dec 14, 2021

This PR adds support for resolving relations in Storyblok. See https://www.storyblok.com/docs/api/content-delivery#core-resources/stories/retrieve-one-story for the resolve_relations param.

If you for example have a blogpost component, with a field 'author', Singe-Option and source Stories:

image

You can add resolve_relations=author when fetching the blogpost. This 'inlines' the author data in the response. When not using resolve_relations you will only get a 'uid' value of the referenced story:

author: ba0a369f-c8b2-465e-ae8d-c94ef68e3d7f

This PR checks if the value of a field is a uid and if so does the request again but then with the resolve_relations option enabled.

As a consumer of the API it's not possible to know upfront that a field is reference to another story, therefore we need to do two requests, which feels wrong, but I don't see another way. Except for maybe adding configuration in backend, where you configure relations per component. But then you always need to add it there too after adding a relation in Storyblok, with this approach it works instantly when changing a component.

ps. not sure why github lists 6 commits instead of 2. I pulled upstream first...

@boldbart boldbart closed this Dec 14, 2021
@boldbart boldbart reopened this Dec 14, 2021
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.

1 participant