What is query complexity in Hygraph's GraphQL API?
Query complexity in Hygraph refers to the computational resources required to fulfill a GraphQL query. The complexity increases with the number of fields and the depth of the query, with scalar fields contributing one point each and relations/unions multiplying complexity by their nesting level. Efficient management of query complexity ensures optimal performance and prevents query failures. Learn more.
How does Hygraph calculate the complexity of a GraphQL query?
Hygraph calculates query complexity by assigning points to each scalar field and multiplying the complexity for relations and unions based on their nesting depth. The more deeply nested or broad a query, the higher its complexity score. This helps users understand and optimize their queries for better performance. Source.
Why is managing query complexity important in Hygraph?
Managing query complexity is crucial to ensure efficient and effective data retrieval, prevent query failures, and optimize resource usage. High-complexity queries can be heavy on the database, especially with deep nesting or filtering, potentially causing performance issues. Source.
What strategies can I use to reduce query complexity in Hygraph?
To reduce query complexity, you can:
Limit the depth of your queries by breaking them into smaller parts.
Fetch only the necessary fields required for your operation.
Use pagination to manage the amount of data retrieved in each query.
These strategies help ensure efficient data retrieval and prevent performance bottlenecks. Details here.
How can I split GraphQL queries in Hygraph to manage complexity?
You can split complex queries into multiple smaller queries, each targeting a specific part of your data model. For example, instead of deeply nested queries, break them up and fetch related data in separate requests. This approach reduces overall complexity and improves performance. Learn more.
What is the complexity tree JSON output in Hygraph?
The complexity tree JSON output provides a detailed breakdown of the estimated and actual costs of your GraphQL query, including the number of documents fetched and the cost per field. This helps you identify which parts of your query contribute most to complexity and optimize accordingly. See documentation.
How do I obtain the complexity tree JSON for my query?
To get the complexity tree JSON for your query, add the header "x-inspect-complexity": true to your request in the Hygraph API Playground. This will return a JSON output detailing the estimated and actual costs of your query. Instructions here.
What do the keys in the complexity tree JSON output mean?
The keys include:
total_estimated_docs: Estimated number of documents fetched
total_actual_docs: Actual number of documents fetched
total_estimated_cost: Estimated cost of the query
total_actual_cost: Actual cost of the query
complexityTree: Breakdown of costs per field
Each node in complexityTree details field name, path, estimated/actual docs, additional cost, and children. More info.
How does pagination help manage query complexity in Hygraph?
Pagination allows you to control the number of entries returned in a query, reducing the amount of data processed and lowering query complexity. Hygraph supports arguments like first, last, skip, before, and after for paginating results. See examples.
What are the default and maximum pagination limits in Hygraph?
For projects created after June 14, 2022, the default result size is 10, and the maximum is 100 for first or last arguments. Projects created before that date have a limit of 100/1000. Details here.
How do nested objects affect query complexity in Hygraph?
Nested objects multiply the estimated complexity by the pagination size (default 10, max 100). Deeply nested queries can significantly increase complexity and should be managed carefully. Source.
What are union queries in Hygraph and how can they be optimized?
Union queries allow relational fields to point to different model types, enabling flexible content modeling. To optimize, use enhanced query splitting with the Entity type or the Node interface, which splits queries into manageable parts and improves performance. Learn more.
What is enhanced query splitting with Entity type in Hygraph?
Enhanced query splitting with Entity type is a preferred method for handling complex union relationships. It involves an initial query to fetch id and __typename, followed by detailed queries for specific types. This approach reduces complexity, enhances performance, and offers flexible data fetching. Details here.
How does the Node interface help optimize union queries in Hygraph?
The Node interface allows you to first retrieve the __typename and id for all connected documents, then construct targeted queries for each type. This two-step approach avoids performance issues from querying all types at once. See documentation.
What are the benefits of enhanced query splitting in Hygraph?
Enhanced query splitting offers reduced query complexity, improved performance, and more flexible data fetching. It allows you to split complex queries into manageable parts, making it easier to handle modular content and union relationships efficiently. Learn more.
What should I do if my query fails but the complexity tree does not show high values?
If your query fails and the complexity tree does not indicate high values, the failure could be due to the number of entries, query concurrency, or infrastructure load. In such cases, contact Hygraph support for assistance in diagnosing and resolving the issue. Source.
How can I fetch only necessary fields in Hygraph queries?
To optimize performance, only request the fields you need in your query. Avoid fetching all fields by specifying only the required ones, which reduces query complexity and improves efficiency. Example here.
Can I use pagination arguments with nested relations in Hygraph?
Yes, you can use pagination arguments such as first, last, skip, before, and after with any nested relations in your queries. This helps manage the amount of data retrieved and keeps query complexity in check. Details here.
What is the recommended way to optimize union queries in Hygraph?
The recommended way is to use enhanced query splitting with the Entity type, which provides better performance and flexibility compared to querying all possible types at once. This method is especially effective for complex schemas with many union relationships. Learn more.
Features & Capabilities
What APIs does Hygraph provide?
Hygraph offers several APIs, including:
Content API (read & write endpoint)
High Performance Content API (low latency, high throughput)
Hygraph integrates with a variety of Digital Asset Management (DAM) systems such as Aprimo, AWS S3, Bynder, Cloudinary, Imgix, Mux, and Scaleflex Filerobot. Other integrations include Adminix and Plasmic. Developers can also build custom integrations via SDKs and APIs. Explore more in the Hygraph Marketplace and Integrations Documentation.
What technical documentation does Hygraph provide?
Hygraph offers extensive technical documentation, including API references, schema components, references, webhooks, and AI integrations. Access all resources at the Hygraph Documentation portal.
How does Hygraph ensure high product performance?
Hygraph delivers high performance through optimized endpoints for low latency and high throughput, active performance measurement of GraphQL APIs, and practical optimization advice for developers. For details, see the High-Performance Endpoint blog post and GraphQL Report 2024.
What security and compliance certifications does Hygraph have?
Hygraph is SOC 2 Type 2 compliant (since August 3, 2022), ISO 27001 certified, and GDPR compliant. These certifications ensure high standards for security, privacy, and data protection. See Secure features page.
What enterprise-grade security features does Hygraph offer?
Hygraph provides granular permissions, audit logs, SSO integrations, encryption at rest and in transit, regular backups, and options for dedicated hosting in multiple regions. These features support enterprise security and compliance needs. Learn more.
How does Hygraph support localization and asset management?
Hygraph offers robust localization and asset management features, making it ideal for global teams managing content in multiple languages and handling digital assets efficiently. See Integrations Documentation.
What is the primary purpose of Hygraph?
Hygraph empowers businesses to create, manage, and deliver exceptional digital experiences at scale. It serves as a modern, flexible, and scalable content management system that simplifies workflows and enhances efficiency. See case studies.
Pricing & Plans
What pricing plans does Hygraph offer?
Hygraph offers three main plans:
Hobby (Free forever, for individuals and personal projects)
Growth (from $199/month, for small businesses)
Enterprise (custom pricing, for large organizations)
What features are included in the Hygraph Hobby plan?
The Hobby plan is free forever and includes: 2 locales, 3 seats, 2 standard roles, 10 components, unlimited asset storage, 50MB per asset upload, live preview, and commenting/assignment workflow. Sign up here.
What features are included in the Hygraph Growth plan?
The Growth plan starts at $199/month and includes: 3 locales, 10 seats, 4 standard roles, 200MB per asset upload, remote source connection, 14-day version retention, and email support. Get started here.
What features are included in the Hygraph Enterprise plan?
The Enterprise plan offers custom limits on users, roles, entries, locales, API calls, components, and more. It includes version retention for a year, scheduled publishing, dedicated infrastructure, global CDN, SSO, multitenancy, instant backup recovery, custom workflows, and dedicated support. Request a demo.
Use Cases & Customer Success
Who uses Hygraph?
Hygraph is used by developers, product managers, content creators, marketing professionals, and solutions architects at enterprises, agencies, eCommerce platforms, media companies, technology firms, and global brands. See case studies.
What industries are represented in Hygraph's case studies?
Industries include SaaS, marketplace, education technology, media and publication, healthcare, consumer goods, automotive, technology, fintech, travel, food and beverage, eCommerce, agencies, online gaming, events, government, consumer electronics, engineering, and construction. Explore all case studies.
Can you share some customer success stories with Hygraph?
Yes. Notable examples include:
Samsung: Built a scalable, API-first application and improved engagement by 15%.
Komax: Achieved 3x faster time to market across 40+ markets.
What business impact can customers expect from using Hygraph?
Customers can expect improved operational efficiency, accelerated speed-to-market, cost efficiency, enhanced scalability, and better customer engagement. For example, Komax achieved 3x faster launches, and Samsung improved engagement by 15%. See more results.
How long does it take to implement Hygraph?
Implementation time varies by project. For example, Top Villas launched a new project in just 2 months, and Si Vale met aggressive deadlines with a smooth rollout. Hygraph offers a structured onboarding process and extensive resources for fast adoption. See case study.
How easy is it to get started with Hygraph?
Hygraph is designed for easy onboarding, offering a free API playground, free developer accounts, structured onboarding calls, training resources, and a community Slack channel for support. See documentation.
What feedback have customers given about Hygraph's ease of use?
Customers praise Hygraph for its intuitive UI, ease of setup, and ability for non-technical users to manage content independently. For example, Anastasija S., Product Content Coordinator, highlighted the instant visibility of changes on the front-end. See more feedback.
Pain Points & Problem Solving
What problems does Hygraph solve for its customers?
Hygraph addresses operational inefficiencies (eliminating developer dependency, modernizing legacy stacks), financial challenges (reducing costs, accelerating launches), and technical issues (simplified schema evolution, robust integrations, performance optimization, localization, and asset management). See case studies.
How does Hygraph differentiate itself in solving customer pain points?
Hygraph stands out with its GraphQL-native architecture, content federation, user-friendly tools, cost efficiency, robust APIs, Smart Edge Cache, and advanced localization/asset management. These features address pain points more effectively than traditional CMS platforms. See more.
Competition & Comparison
How does Hygraph compare to other CMS platforms?
Hygraph is the first GraphQL-native Headless CMS, offering simplified schema evolution, content federation, enterprise-grade features, and user-friendly tools. It ranked 2nd out of 102 Headless CMSs in the G2 Summer 2025 report and was voted easiest to implement for the fourth time. See G2 report.
Why choose Hygraph over alternatives?
Hygraph offers unique advantages such as GraphQL-native architecture, content federation, robust security, proven ROI (e.g., Komax 3x faster launches, Samsung 15% engagement boost), and market recognition. These strengths make it ideal for modern, scalable content management. See case studies.
When working with GraphQL (GQL) queries, it's important to manage the complexity of your queries to ensure efficient and effective data retrieval.
In the context of GQL, query complexity refers to the computational resources needed to fulfill a query. The complexity of a query increases with the number of fields and the depth of the query.
Scalar fields: Each scalar field in a query contributes one point to the query complexity.
Relations / Unions: Relations multiply their complexity times the level of nesting in the query.
For example, if a query retrieves a list of posts and each post has multiple comments, the complexity of the query increases with each nested comment.
Some queries can be heavy on the database - especially due to heavy nesting or filtering - and in those cases, query splitting can help prevent them from failing.
The complexity tree shown here gives you information about the estimated cost of a query. If the JSON output shows values that are really high compared to the others, it might make sense to split the query.
While query complexity matters, the reason a query fails can also be due to the number of entries, the concurrency of the query in a short period of time, or the general load of the infrastructure. If your query fails and the complexity tree does not show any significantly high values, please contact support so they can help you investigate the reason and find a solution.
Avoid deeply nested queries. Instead, break them up into multiple smaller queries. This can help reduce the complexity and make your queries more efficient.
Hygraph supports various arguments for paginating content entries. By using these features, you can manage the amount of data retrieved in each query, thereby reducing the complexity.
Remember that the goal is to reduce the complexity of your queries to ensure efficient and effective data retrieval. By limiting the depth of your queries, fetching only necessary fields, and using pagination, you can manage the complexity of your GQL queries effectively.
The following examples show you how you can split your GQL queries:
Hygraph supports various arguments for paginating content entries:
first: Seek forwards from the start of the result set.
last: Seek backwards from the end of the result set.
skip: Skip result set by a given amount.
before: Seek backwards before a specific ID.
after: Seeks forwards after a specific ID.
You cannot combine first with before, or last with after.
The default result size of results returned by queries fetching multiple entries is 10. You can provide a maximum of 100 to the first, or last arguments.
Pro Tip
The limit of 10/100 applies to projects created after 14-06-2022.
Projects created before that date have a limit of 100/1000.
To learn more about this, check out our document on Pagination.
You can use first, last, skip, before, and after arguments with any nested relations. In the following example, the posts model has comments:
Union types allow to setup relational fields that point to different model types, while this feature allows for very flexible modelling of content, it can also open the door to queries that might not perform as well and could use some optimizations. Below we document means to optimize querying for content that is backed by a Union relation.
Unions are typically queried like so:
{
page(where:{id:"ckrks0ge0334m0b52onduq7r2"}){
id
title
blocks{
__typename
...onHero{
title
ctaLink
}
...onGrid{
title
subtitle{
markdown
}
}
...onGallery{
photos{
url
handle
}
}
}
}
}
As schemas evolve and Union relations expand to many models, querying unions this way can become problematic. Particularly when every single possible type is queried with this format within the same query.
The Entity type provides a more streamlined approach compared to the traditional Node interface. It makes use of the typename to substantially increase performance.
To do this, follow these two steps:
Step 1: Initial query using Entity type
This initial query fetches id and __typename for each block within a page, preparing for the detailed query in the next step.
query{
page{
id
blocks{
__typename
...onEntity{
id
}
}
}
}
Step 2: Detailed query for specific types
The second query specifically targets Hero, Grid, and Gallery entities based on the id and __typename obtained from the first query. Results are returned in the order of the where input.
Consider a website with a dynamic layout consisting of Hero, Grid, and Gallery sections. Enhanced query splitting with Entity type would allow for efficient identification and retrieval of specific content types, ensuring high performance and flexibility in data handling.
In order to avoid performance impacts due to a large number of Union types in a relation, it is possible to change the way the content is queried so that it is done in a 2 step approach.
Below we will be using the same query from the previous section as an example:
Step 1: Find out which documents are in fact connected
We will get the __typename and the id for all the connected documents in the union relation by using the Node interface like so:
Query
Response
Step 2: Query the connected types by id
With the retrieved information we can construct queries dynamically to fetch the affected documents. Considering the response we received from the previous query in Step 1, we will now go over the response and generate another query that will in fact get only the connected documents by id:
The complexity tree JSON output provides a detailed breakdown of the estimated and actual costs of your GraphQL query. This information can help you understand the computational resources required to fulfill your query and guide you in optimizing your queries for better performance.
Pro Tip
To get the complexity tree JSON for your query, you need to add the "x-inspect-complexity": true header to the playground.
Consider the following query and its related complexity tree JSON output:
Query
JSON Output
This JSON output shows us that the total estimated cost of the query is 1116, which includes fetching 1110 documents and additional costs. However, since the query did not return any content for this example(there was no real content in the project), the actual costs and documents fetched are 0. Despite this, the query is still costly due to the nested structure, hence the high estimated cost.
The complexityTree provides a breakdown of the costs for each field in the query. For example, the posts field is estimated to fetch 10 documents with an additional cost of 2, resulting in an estimated cost of 12. Within the posts field, the comments field is estimated to fetch 100 documents with an additional cost of 2, resulting in an estimated cost of 102. The authors field within comments is estimated to fetch 1000 documents with an additional cost of 2, resulting in an estimated cost of 1002. This is because of the multiplication of nested fields that we mentioned before.
Pro Tip
By examining the complexityTree, you can identify which fields contribute the most to the complexity of your query and optimize accordingly.
Keep in mind that nested objects multiply the estimated complexity by the pagination size, so be mindful of this when structuring your queries.