After some team shifting, I’ve inherited an early stage project using Gatsby and GraphQL for dynamic pages constructed by content authors. There is a page model with a content field that allows linking to multiple components, and each of those components can contain modular content blocks. The page query has fragments for each component type and those component fragments contain fragments for their supported blocks like what is explained here. Static pages are being built using switch statements on the __typename similar to the answer in this post.
Since this project is still in its infancy, all of that is working great. But as more components get built, I’m concerned about running into limit issues with query complexity. I’ve been experimenting with the model and block fragments I do have in the API Explorer, and it seems like the x-complexity value is calculated from the most complex fragment path rather than all fragments. Is that a correct understanding? For example, the query below scores at 110. If I only remove the HeroComponentRecord fragment, it still scores at 110. If I only remove the ListComponentRecord fragement the score drops to 97. If I add a 2nd field to NumberListItemRecord I still get 110, but if I add a 3rd field I get 111 because the NumberListItemRecord fragment now requests more fields than the StatisticListItemRecord fragment. If that understanding is correct, then it seems like I shouldn’t run into any limit issues if I continue down this path for component development.
{
allPages {
id
pageTitle
titleSuffix
pageContent {
__typename
... on ListComponentRecord {
title
subtitle
theme
listItems {
__typename
... on NumberedListItemRecord {
text
}
... on StatisticListItemRecord {
description
source
}
}
}
... on HeroComponentRecord {
subtitle
header
createdAt
}
}
}
}