excluding_fields on resolve_relations


I’m currently creating a blog with storyblok. The site itself is static Next js .
In our structure we allow the editor the reference other posts inside a post (using the multiselect field inside a “list” component).
These list components can be nested in a body field. So multiple lists can be added in between other content.
To fetch the data of the page (in getStaticProps) I’m using the javascript SDK (GitHub - storyblok/storyblok-js-client: Universal JavaScript SDK for Storyblok's API). with the resolve_relations param I’m able to get the get the related posts. However there is a problem that the returned data gets very large(+5mb).
I think this is mainly because the related posts return all their data (including the body field with their own lists)

Is there a way to exclude fields from returned posts (in the related content)? If we can exclude the body field and only fetch the post title and image, we will reduce the amount of data to a workable amount

Hello @bregtemundo,

yes, you can use the excluding_fields (Storyblok API Documentation) parameter which allows you to define fields inside of the content type to exclude from the response.

Here is an example for its usage: https://api.storyblok.com/v2/cdn/stories/?version=draft&token=B5SgCwggHLFGverwDYLIQAtt&cv=1647866654&starts_with=global-reusable-content/image-content&resolve_relations=option_field.option_field,Multi_Option_Field.Multi_Option_Field,nestedrelations.Multi_Option_Field&excluding_fields=boolean,link,nestedrelations,colorpicker

Best regards