Join the Webstudio community

Updated 2 months ago

Best practice for GraphQL data fetching in root vs page-level queries

At a glance

The community member is asking whether it's a good practice to include full GraphQL queries (with rich content like long ACF text fields) in root-level data fetches, or if it would be more optimal to only fetch essential metadata (like IDs, slugs, and short titles) in the root, and then fetch full content on page-level only when needed. The concern is about performance when the same root query runs across many pages.

In the comments, another community member understands that if a query is added to the root, it will be done on all templates. The response confirms this, and mentions that in the future, usage detection will be improved.

In Webstudio, is it a good practice to include full GraphQL queries (with rich content like long ACF text fields) in root-level data fetches? Or would it be more optimal to only fetch essential metadata (like IDs, slugs, and short titles) in the root, and then fetch full content (e.g. description, content, conclusion) on page-level only when needed? I’m concerned about performance when the same root query runs across many pages.
D
B
2 comments
In short: I understand that if I add a query to root, it will be done on all templates?
Yes, at the moment. In the future we will improve usage detection.
Add a reply
Sign up and join the conversation on Discord