Frequently Asked Questions

API Filtering & Technical Features

What types of filters does Hygraph support in the Content API?

Hygraph supports a wide range of filters in the Content API, including filters for ID, String, Integer, Float, Boolean, Date, DateTime, Basic Reference, Union Reference, Enumeration, Taxonomy, Asset, and JSON fields. Each filter type allows for specific query behaviors, such as equality, range, inclusion, exclusion, and more. For a full list, see the Filter Types documentation.

How do I use the 'where' argument to filter content entries in Hygraph?

To filter content entries, pass the where argument to your GraphQL query, followed by the relevant filter types for your model's fields. For example, you can filter posts by author name or products by quantity. The API Playground provides an interactive way to explore available filters for your schema. See Using Filters for details.

Can I filter by multiple criteria or combine filters in Hygraph?

Yes, Hygraph allows you to combine multiple filters using logical operators such as AND, OR, and NOT. This enables complex queries, such as fetching entries that meet several conditions simultaneously. Nested filters are also supported. See Combining Filters for examples.

How does filtering work for different field types in Hygraph?

Filtering behavior depends on the field type. For example, String fields support filters like _contains, _starts_with, and _ends_with; Integer and Float fields support range filters like _lt, _gt, _lte, and _gte; Boolean fields can be filtered directly or with _not. Array fields support contains_all, contains_none, and contains_some. See Filter Types for details.

Are there any limitations to filtering in Hygraph?

Hygraph does not currently support filtering for Rich Text fields (even inside components), JSON multi-value fields, colors, or coordinates. For supported field types, see the documentation.

How can I filter content by stage or locale in Hygraph?

You can filter content entries by stage (such as DRAFT, PUBLISHED, or custom stages) and by locales for localization. The stage argument determines which document variation is returned, while the locales argument filters content by language. See Filter by Locales and Filter by Stage Argument for more information.

How do I filter JSON fields in Hygraph?

Hygraph supports filtering JSON fields using value_recursive for exact value matches and json_path_exists for advanced queries based on JSON path syntax. You can filter by quantity, string, null, or range within JSON fields. See JSON Filtering for examples and syntax.

Can I filter by references and components in Hygraph?

Yes, you can filter by references (relations) and components. For references, use filters like _every, _some, and _none to match conditions on related models. For components, similar filters apply depending on whether the field allows multiple values. See Basic Reference and Basic Component for details.

How does filtering work for enumeration and taxonomy fields?

Enumeration fields can be filtered using _not, _in, and _not_in operators, based on the enumeration values defined in your schema. Taxonomy fields support filters like _not, _in, _not_in, contains_all, contains_some, contains_none, and descendants_of. See Enumeration and Taxonomy for more details.

What is the difference between filtering in the API and the UI for content stages?

In the UI, stages are presented in an editor-friendly way (e.g., a green 'PUBLISHED' pill). In the API, every entry always exists in the DRAFT stage, and other stages are added or removed. Filtering by stage in the API allows for more granular queries, such as finding documents that exist in multiple stages. See Filter by Content Stage for more details.

How do I filter for documents that exist only in a specific stage?

To filter for documents that exist only in a specific stage (e.g., PUBLISHED), you need to use a combination of AND and NOT meta filters. This approach allows you to intersect queries and find documents that meet your criteria. See Filter by Content Stage for query examples.

What is 'compareWithParent' in Hygraph filtering?

The compareWithParent filter allows you to compare a document with its parent entry using comparison operators, such as checking if a child document is outdated compared to its parent. Currently, it is available only inside a documentInStages_* filter and supports the outdated_to attribute. See documentation for usage.

How do I explore available filters for my schema in Hygraph?

The best way to explore available filters is by using the API Playground. It provides an interactive environment to test queries and view filter options for your schema.

Can I filter assets and asset fields in Hygraph?

Yes, asset fields can be filtered using standard operators and system fields, such as fileName. You can filter assets through references or when querying all assets. See Asset Filtering for examples.

Does Hygraph support conditional filters for complex queries?

Yes, Hygraph supports conditional filters using AND, OR, and NOT operators, which can be nested for complex query logic. This allows you to fetch entries based on multiple criteria. See Conditional Filters for more details.

How do I filter for null references in Hygraph?

You can filter single and multi-reference fields for empty references using _every: {}, _some: {}, and _none: {}. These filters help you find entries with or without connected references. See Null References for details.

Can I filter union and nested union fields in Hygraph?

Yes, union fields can be filtered using _empty and _some operators. Nested unions allow you to filter data from different levels within your schema. See Union Reference and Nested Unions for more information.

How do I filter modular and nested components in Hygraph?

Modular component fields that allow multiple values can be filtered using _empty and _some. Nested components can be filtered at different levels using these operators. See Modular Component and Nested Components for details.

What are some practical examples of filtering queries in Hygraph?

Examples include filtering products by quantity (quantity_in: [10, 100, 1000]), filtering posts by verified status (verified: true), filtering events by date range (day_gt: "2020-10-07"), and filtering JSON fields by value or range. See the Query Syntax Examples for more.

Features & Capabilities

What are the key capabilities and benefits of Hygraph?

Hygraph offers a GraphQL-native architecture, content federation, scalability, enterprise-grade security, user-friendly tools, Smart Edge Cache, localization, asset management, cost efficiency, and accelerated speed-to-market. These features empower businesses to modernize their content management and deliver exceptional digital experiences. Source: manual.

Does Hygraph provide APIs for content management?

Yes, Hygraph provides multiple APIs: Content API (read & write), High Performance Content API (low latency, high throughput), MCP Server API (AI assistant integration), Asset Upload API, and Management API. For details, see the API Reference Documentation.

What integrations are available with Hygraph?

Hygraph integrates with Digital Asset Management systems (Aprimo, AWS S3, Bynder, Cloudinary, Imgix, Mux, Scaleflex Filerobot), Adminix, Plasmic, and supports custom integrations via SDK and external APIs. Marketplace apps are also available. See Integrations Documentation.

What technical documentation does Hygraph offer?

Hygraph provides extensive technical documentation, including API reference, schema components, references, webhooks, and AI integrations (AI Agents, AI Assist, MCP Server). Access all resources at Hygraph Documentation.

How does Hygraph perform in terms of speed and reliability?

Hygraph is designed for high performance, with low latency and high read-throughput endpoints. Performance is actively measured and optimized, as detailed in the High-Performance Endpoint blog and GraphQL Survey 2024.

What security and compliance certifications does Hygraph have?

Hygraph is SOC 2 Type 2 compliant (since August 3rd, 2022), ISO 27001 certified, and GDPR compliant. It offers enterprise-grade security features such as granular permissions, audit logs, SSO, encryption, backups, and dedicated hosting. See Secure Features for details.

How easy is it to set up and start using Hygraph?

Hygraph offers a free API Playground, free forever developer account, structured onboarding (intro call, account provisioning, business/technical/content kickoff), training resources, extensive documentation, and a community Slack channel. For example, Top Villas launched a new project in just 2 months. See Top Villas Case Study.

What feedback have customers given about Hygraph's ease of use?

Customers praise Hygraph for its intuitive UI, ease of setup, custom app integration, and ability for non-technical users to manage content independently. Real-time changes and reduced bottlenecks are frequently cited. Source: Try Headless CMS, Enterprise Page.

What pain points does Hygraph address for its customers?

Hygraph solves operational inefficiencies (developer dependency, legacy tech stacks, content inconsistency), financial challenges (high costs, slow speed-to-market, scalability), and technical issues (complex schema evolution, integration difficulties, performance bottlenecks, localization, asset management). Source: Hailey Feed - PMF Research.xlsx.

How does Hygraph differentiate itself from other CMS platforms?

Hygraph is the first GraphQL-native Headless CMS, offering content federation, enterprise-grade features, user-friendly tools, scalability, and proven ROI. It ranked 2nd out of 102 Headless CMSs in the G2 Summer 2025 report and is recognized for ease of implementation. Source: Case Studies, G2 Summer 2025.

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 time-to-market, and Samsung improved engagement by 15%. Source: Case Studies.

Who is the target audience for Hygraph?

Hygraph is designed for developers, product managers, content creators, marketing professionals, and solutions architects at enterprises, agencies, eCommerce platforms, media companies, technology firms, and global brands. Source: ICPVersion2_Hailey.pdf, 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 and hospitality, food and beverage, eCommerce, agency, online gaming, events & conferences, government, consumer electronics, engineering, and construction. See Case Studies.

Can you share specific customer success stories using Hygraph?

Yes. Samsung built a scalable, API-first application; Dr. Oetker enhanced digital experience with MACH architecture; Komax achieved 3x faster time to market; AutoWeb saw a 20% increase in monetization; BioCentury accelerated publishing; Voi scaled multilingual content; HolidayCheck reduced bottlenecks; Lindex Group accelerated global delivery. See Case Studies.

Who are some of Hygraph's notable customers?

Notable customers include Samsung, Dr. Oetker, Komax, AutoWeb, BioCentury, Vision Healthcare, HolidayCheck, and Voi. See Case Studies for more details and customer logos.

Pricing & Plans

What is Hygraph's pricing model?

Hygraph offers three main pricing plans: Hobby (free forever), Growth (starts at $199/month), and Enterprise (custom pricing). Each plan includes different features and limits. See Pricing Page for details.

What features are included in the 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, commenting, and assignment workflow. Sign up for the Hobby plan.

What features are included in the 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 desk. Get started with the Growth plan.

What features are included in the Enterprise plan?

The Enterprise plan offers custom limits on users, roles, entries, locales, API calls, components, remote sources, version retention (1 year), scheduled publishing, dedicated infrastructure, global CDN, 24/7 monitoring, security controls, SSO, multitenancy, backup recovery, custom workflows, dedicated support, and custom SLAs. Try the Enterprise plan for 30 days or request a demo.

Support & Implementation

How long does it take to implement Hygraph?

Implementation time varies by project complexity. For example, Top Villas launched in 2 months, and Si Vale met aggressive deadlines with a smooth initial phase. Hygraph's onboarding and training resources support fast adoption. Source: Top Villas Case Study, Si Vale Case Study.

What support resources are available for Hygraph users?

Hygraph provides webinars, live streams, how-to videos, extensive documentation, and a community Slack channel for support and guidance. Enterprise customers receive dedicated support and custom SLAs. See Documentation and Slack Channel.

How does Hygraph handle security incidents and reporting?

Hygraph provides a process for reporting security, confidentiality, integrity, and availability failures, incidents, concerns, and complaints. See Secure Features for more information.

Use Cases & Benefits

What core problems does Hygraph solve?

Hygraph eliminates developer dependency, modernizes legacy tech stacks, ensures content consistency, improves workflows, reduces costs, accelerates speed-to-market, simplifies schema evolution, integrates third-party systems, optimizes performance, and enhances localization and asset management. Source: Hygraph knowledge_base.

What are some case studies relevant to each pain point Hygraph solves?

Operational: HolidayCheck reduced bottlenecks; Dr. Oetker adopted MACH architecture; Si Vale streamlined content creation. Financial: Komax achieved faster launches and lower costs; Samsung scaled globally with reduced overhead. Technical: Hygraph case studies highlight simplified development and robust integrations. See Case Studies.

How does Hygraph's approach to solving pain points differ from competitors?

Hygraph offers a user-friendly interface, GraphQL-native architecture, content federation, cost efficiency, accelerated speed-to-market, robust APIs, Smart Edge Cache, and enhanced localization and asset management. Its focus on flexibility, scalability, and integration sets it apart from traditional CMS platforms. Source: Hailey Feed - PMF Research.xlsx.

What is the primary purpose of Hygraph?

Hygraph empowers businesses to create, manage, and deliver exceptional digital experiences at scale, serving as a modern, flexible, and scalable content management system that simplifies workflows and enhances efficiency. Source: manual.

Help teams manage content creation and approval in a clear and structured way
Hygraph
Docs

#Filtering

#Overview

Hygraph automatically creates filters for types you add to your content models. These filters can be applied to a single, or multiple entries, and nested object fields.

The best place to explore all available filters is by using the API Playground.

#Using filters

To filter content entries, simply pass the where argument to the query, followed by any of the filter types for the fields on your model.

For example, a Post model will have the where input types PostWhereInput and PostWhereUniqueInput on the posts, and postsConnection query types. These types contain filters specific to that content type.

#Filter types

#ID

Entries can be filtered by id.

MatchesTypeBehavior
idIDEqual to
id_notIDNot this (null accepted)
id_in[ID!]One of
id_not_in[ID!]Not one of
id_starts_withIDStarts with
id_not_starts_withIDDoes not start with
id_ends_withIDEnds with
id_not_ends_withIDDoes not end with
id_containsIDContains
id_not_containsIDDoes not contain

#String

All String fields can be filtered using:

MatchesTypeBehavior
[fieldName]_notStringNot this (null accepted)
[fieldName]_in[String]One of
[fieldName]_not_in[String]Not one of
[fieldName]_starts_withStringStarts with string
[fieldName]_not_starts_withStringDoesn't start with string
[fieldName]_ends_withStringEnds with string
[fieldName]_not_ends_withStringDoesn't end with string
[fieldName]_containsStringIncludes string
[fieldName]_not_containsStringDoes not include string

#Integer

All Integer fields can be filtered using:

MatchesTypeBehavior
[fieldName]_notIntNot this (null accepted)
[fieldName]_in[Int]One of
[fieldName]_not_in[Int]Not one of
[fieldName]_ltIntLess than
[fieldName]_gtIntGreater than
[fieldName]_lteIntLess than or equal to
[fieldName]_gteIntGreater than or equal to
{
products(where: { quantity: 100 }) {
quantity
}
multipleQuantities: products(where: { quantity_in: [10, 100, 1000] }) {
quantity
}
}

#Float

All Float fields can be filtered using:

MatchesTypeBehavior
[fieldName]_notFloatNot this (null accepted)
[fieldName]_in[Float]One of
[fieldName]_not_in[Float]Not one of
[fieldName]_ltFloatLess than
[fieldName]_gtFloatGreater than
[fieldName]_lteFloatLess than or equal to
[fieldName]_gteFloatGreater than or equal to
{
products(where: { rating: 4.5 }) {
name
rating
}
}

#Boolean

All Booleans belonging to your content model can be filtered using the field name directly, as well as appended with _not, with a Boolean input type.

MatchesTypeBehavior
[field]BooleanIs
[field]_notBooleanFlips boolean (null not taken into account)

For example, let's filter posts where the custom field verified is true:

{
posts(where: { verified: true }) {
id
}
posts(where: { verified_not: true }) {
id
}
}

#Date

All Date fields can be filtered using:

MatchesTypeBehavior
[fieldName]_notDateNot this (null accepted)
[fieldName]_in[Date]One of
[fieldName]_not_in[Date]Not one of
[fieldName]_ltDateLess than
[fieldName]_gtDateGreater than
[fieldName]_lteDateLess than or equal to
[fieldName]_gteDateGreater than or equal to
{
today: events(where: { day: "2020-10-07" }) {
day
}
upcoming: events(where: { day_gt: "2020-10-07" }) {
day
}
}

#DateTime

Hygraph stores Date/DateTime fields as UTC strings, ISO 8601.

Like Date fields, DateTime fields can be filtered using:

MatchesTypeBehavior
[fieldName]_notDateTimeNot this (null accepted)
[fieldName]_in[DateTime]One of
[fieldName]_not_in[DateTime]Not one of
[fieldName]_ltDateTimeLess than
[fieldName]_gtDateTimeGreater than
[fieldName]_lteDateTimeLess than or equal to
[fieldName]_gteDateTimeGreater than or equal to
{
events(where: { start: "2020-10-07T09:00:00+00:00" }) {
start
}
previous: events(where: { start_lt: "2020-10-07T09:00:00+00:00" }) {
start
}
}

#Basic Reference

All relations (except Unions) can be filtered using filters on the fields of the model you are referencing. You can filter where every, some, and none at all match the conditions provided.

MatchesBehavior
[fieldName]_everyEvery reference matches
[fieldName]_someSome references match
[fieldName]_noneNo references match

For example, you could fetch every post by the provided author name.

{
posts(where: { authors_every: { name_in: ["John", "Simona"] } }) {
title
authors {
name
}
}
}

#Null references

It is possible to filter on single, and multi reference fields for when these references are empty.

  • [fieldName]_every: {}: Returns all authors, with or without connected posts
  • [fieldName]_some: {}: Returns all authors with at least one connected post
  • [fieldName]_none: {}: Returns all authors that have no posts connected

#Union reference

Using the where filter, you can filter by unions to get into the models and even fields inside of them.

You can combine the where filter with the following:

MatchesTypeBehavior
[FieldName]_emptyBooleanIf true, it returns every result where the filtered union is not connected / is empty
[FieldName]_someArrayMatches if the union contains at least one connection to the item provided to the filter

#Nested unions

Using filters allows going into the reverse field and getting information from the start model.

#Basic component

#Basic component field allows multiple values

All basic component fields that allow multiple values can be filtered using:

MatchesBehaviour
[fieldName]_everyEvery reference matches
[fieldName]_someSome references match
[fieldName]_noneNo references match

#Basic component field doesn't allow multiple values

If the basic component field does not allow multiple values, the _every, _some, and _none filters are unavailable, but you can query for a match as well as for empty components.

#Modular component

All modular component fields that allow multiple values can be filtered using:

MatchesTypeBehavior
[FieldName]_emptyBooleanIf true, it returns every result where the filtered model is empty
[FieldName]_someArrayMatches if the model contains at least one connection to the item provided to the filter

#Nested components

You can use the above filters to filter data from different levels of nested components as follows:

#Enumeration

All Enum fields can be filtered by using:

MatchesTypeBehavior
[fieldName]_notEnumerationValueNot this (null accepted)
[fieldName]_in[EnumerationValue]One of
[fieldName]_not_in[EnumerationValue]Not one of

The type of enumeration you can filter by will be the actual Enumeration values defined in your schema.

{
resources(where: { type_in: [Webinar, Ebook] }) {
id
}
}

#Taxonomy

All Taxonomy fields can be filtered by using:

MatchesTypeBehavior
[fieldName]_notTaxonomyNodeWhereInputNot this (null accepted)
[fieldName]_in[TaxonomyNodeWhereInput!]One of
[fieldName]_not_in[TaxonomyNodeWhereInput!]Not one of
[fieldName]_contains_all[TaxonomyNodeWhereInput!]Contains all specified values
[fieldName]_contains_some[TaxonomyNodeWhereInput!]Contains at least one of the specified values
[fieldName]_contains_none[TaxonomyNodeWhereInput!]Contains none of the specified values
[fieldName]_descendants_of[TaxonomyNodeWhereInput!]Returns the specified taxonomy node and all nodes below it (descendants)

You can filter the taxonomy by the taxonomy node names defined in your schema.

#Asset

All Asset fields can be filtered using:

MatchesTypeBehavior
[fieldName]_notStringNot this (null accepted)
[fieldName]_in[String]One of
[fieldName]_not_in[String]Not one of
[fieldName]_ltStringLess than
[fieldName]_gtStringGreater than
[fieldName]_lteStringLess than or equal to
[fieldName]_gteStringGreater than or equal to
[fieldName]_everyRelation TypeEvery reference matches
[fieldName]_someRelation TypeSome references match
[fieldName]_noneRelation TypeNo references match

Asset fields come with their own System Fields which you can apply these filters on, as well as any custom fields, or references you add.

You can filter the asset through the reference, or when querying all assets.

For example, we could fetch posts where the coverImage field meets the provided criteria on the system field fileName:

{
posts(where: { coverImage: { fileName: "image.png" } }) {
id
coverImage {
fileName
}
}
}

#Combining filters

Just like combining query arguments, it is also possible to combine filters.

{
events(
where: {
start_gt: "2020-10-01T09:00:00+00:00"
start_lt: "2020-10-31T09:00:00+00:00"
fancyDress: true
price: 100
}
) {
start
fancyDress
price
}
previous: events(where: { start_lt: "2020-10-07T09:00:00+00:00" }) {
start
}
}

#Conditional filters

Hygraph supports conditional filters for your content using AND, NOT and OR. Useful for filtering results based on more than one criteria.

Input TypeDescription
ANDFetch entries that meet both conditions.
ORFetch entries that match either condition.
NOTFetch all entries where the conditions do not match.

#Filter by locales

When querying content entries, you can also filter by locales:

{
posts(locales: [en]) {
id
}
}

Learn more about localization.

#Filter by stage argument

When querying content entries, you can also filter by stage. The stage argument decides what document variation gets returned and searched through. Therefore, if the document does not exist in the stage variation, it gets filtered out.

{
posts(stage: PUBLISHED) {
id
stage
}
}

Learn more about content stages.

#Filter by content stage

Stages work a bit differently in the API than in the UI. In the UI, we use the most intuitive and editor-friendly way of treating filters. So, for instance, if you see a green PUBLISHED pill next to an entry, then this entry is only in the PUBLISHED stage. However, in the backend, our stages are organized slightly differently. The main difference is that each content entry always exists in DRAFT, and other stages are added or removed. For example, an entry that has a green PUBLISHED pill in the UI is actually in both DRAFT and PUBLISHED stages on the API side, and both versions of the entry are identical. If you update the DRAFT version but don't publish it, the entry will continue to exist in both stages, but will be marked as blue PUBLISHED in the UI.

Stages can be filtered using:

MatchesBehavior
documentInStages_everyAll existing stage variations must match the sub-filter
documentInStages_someAt least one of the existing stage variations must match the sub-filter
documentInStages_noneNone of the existing stage variations are allowed to match the sub-filter

To summarize, like we mentioned before, a document will always exist in the DRAFT stage, and they may or may not exist in other published stages such as PUBLISHED or for example QA - which is a custom content stage that can be published to.

If you, as a user, want to find documents that exist in the PUBLISHED stage, you can run the following query:

stage: DRAFT
where: {
documentInStages_some: {
stage: PUBLISHED
}
}

The above documentInStages_some allows the user to find documents which exist in a different stage. Let's consider the following 3 documents, which exist in the following stages:

IDSTAGES
cldocument1[DRAFT, PUBLISHED]
cldocument2[DRAFT]
cldocument4[DRAFT, PUBLISHED, QA]

The above query will return documents that also exist in the PUBLISHED stage, which are cldocument1 and cldocument4.

However you may have noticed that cldocument4 also has been published to the QA stage - If you have access to custom stages.

Imagine you want to query documents which exist only in one published stage PUBLISHED, but not any other publishable stages. In this case the result you want is cldocument1. For this we can use documentInStages_every.

Keeping in mind that a document entry can exist in multiple stages, the difference between documentInStages_some and documentInStages_every is that documentInStages_some checks if an entry exists in a particular stage, whereas by using documentInStages_every we request an entry that exists in only and exactly that stage. So if we use documentInStages_every with PUBLISHED the query will return results only if the document exists in PUBLISHED and no other stage.

You might read this and try a query such as the following:

where: {
documentInStages_every: {
stage: PUBLISHED
}
}

While you are on the right track, this will unfortunately return no results. The reason is that, as we mentioned earlier, every document always exists in DRAFT, so no document will ever only exist in PUBLISHED.

If you try changing the above PUBLISHED to DRAFT, however, you will get cldocument2 as a result, as this document only exists in the DRAFT stage.

As a workaround for this problem, we can use the OR meta filter, by using the following query:

where: {
documentInStages_every: {
OR: [
{
stage: DRAFT
},
{
stage: PUBLISHED
}
]
}
}

Since the internal query is that the stage must exist either in DRAFT or PUBLISHED, the query evaluates to true for both document cldocument1 and cldocument2. It skips cldocument4, which is what we want, but we still get cldocument2 which exists only in DRAFT.

We can use the same pattern of using meta filters to filter out the DRAFT entry. Let's start by writing this query:

where: {
NOT: [
{
documentInStages_every: {
stage: DRAFT
}
}
]
}

As you can see, this query returns any document that does not exist only in DRAFT, Which in this case would be cldocument1 and cldocument4. If we were to do an intersection of the results of the above two queries, we would get cldocument1, which is the document that we want.

In order to do this, we combine the above two queries to create the following:

where: {
AND: [
{
documentInStages_every: {
OR: [
{
stage: DRAFT
},
{
stage: PUBLISHED
}
]
}
},
{
NOT: [
{
documentInStages_every: {
stage: DRAFT
}
}
]
}
]
}

As you can see above, by using the AND meta filter we get the intersection between the two queries above, which returns the cldocument1 document.

compareWithParent

compareWithParent allows the comparison of a document with its parent entry using any comparison operators available within it.

At the moment compareWithParent is available only inside a documentInStages_* filter, and only allows the use of one attribute which is outdated_to. This attribute can be found inside the compareWithParent filter. The attribute is used to specify if we wish to check whether the child document is outdated compared to the parent document. For example:

variousDocuments(
stage: DRAFT
where: {
documentInStages_some: {
stage: PUBLISHED
compareWithParent: {
outdated_to: true
}
}
}
)

In the above example, we enable the filter by setting outdated_to to true - if it were set to false, it would be the same as having the filter omitted entirely. The true and false values are simply indicators of whether to process the filter in the query.

In the above query, we check if the child PUBLISHED version is outdated compared to the DRAFT parent version. At the moment, we check if a document is outdated by comparing the updatedAt attributes of both the DRAFT and PUBLISHED versions. If the DRAFT has a greater updatedAt, that means the document has been modified since it was last published, and is therefore considered outdated.

#JSON filtering

You can filter the data in the JSON fields of your Hygraph project using the following filters.

#value_recursive

You can filter the data in your JSON fields by using the following value_recursive syntax to find exact matches:

query for {
posts(where: { jsonField_value_recursive: "hallo" }) {
id
jsonField
}
}

The query above would search the JSON fields for an exact match of "hallo" on all values, excluding the json keys.

#json_path_exists

You can filter the data in your JSON fields by using json_path_exists syntax from PostgreSQL.

To be able to query this content, you need to know the JSON structure to navigate through it.

If you're not familiar with the structure, you can query for all content - without passing a filter, or with just a pagination filter depending on number of entries - and look into it. A great way to go about this kind of exploration is using the API Playground, where you can type “json” then use ctrl + space or command + space to display all the filters you can use and select one.

#Query syntax examples

Imagine we have the following content data in a JSON field which allows multiple values:

"data": {
"testFieldsModels": [
{
"listJsonField": [
{
"items": {
"qty": 24,
"product": "Diaper"
},
"customer": "Lily Bush"
},
{
"items": {
"qty": 1,
"product": "Toy Car"
},
"customer": "Josh William"
},
{
"items": {
"qty": null,
"product": "Headphones"
},
"customer": "James Buyer"
}
]
}
]
},

Using the above sample content data, here are some query examples:

 

Query by quantity

You can use "$[*].** ? (@ > N)” to filter all values all for integers above a certain number. Just replace N with the number of your choice.

query for {
testFieldsModels(
where: { listJsonField_json_path_exists: "$[*].items.qty ? (@ > 5)" }
) {
listJsonField
}
}

The above query example returns products with a quantity greater than 5.

 

Query by string

You can use "$.** ? (@ == \"String\")” to filter all values all for the matching string:

query for {
testFieldsModels(
where: {
listJsonField_json_path_exists: "$.items.product ? (@ == \"Toy Car\")"
}
) {
listJsonField
}
}

The above query example returns products with the name “Toy Car”.

 

Query by null

You can use "$[*].** ? (@ == null)” to filter all values all for null.

query for {
testFieldsModels(
where: { listJsonField_json_path_exists: "$[*].items.qty ? (@ == null)" }
) {
listJsonField
}
}

The above query example returns items where quantity (qty) = null.

 

Query by range

You can use "$[*].** ? (@ > N && @ < N)” to filter all values all for a range of numbers. Just replace N with the numbers of your choice.

query for {
testFieldsModels(
where: {
listJsonField_json_path_exists: "$[*].items.qty ? (@ > 1 && @ < 5)"
}
) {
listJsonField
}
}

The above query example returns items with a quantity between 1 and 5.