Update: As of 2024, Deep Filtering is officially released and no longer in beta! Please see our docs for usage guidelines or this newer blog post for a detailed walkthrough.
We're excited to announce the public beta launch (released as of 2024!) of Deep Filtering, a new feature available in the Content Delivery API of DatoCMS. Deep Filtering enables you to filter records based on the content within their embedded blocks, bringing more flexibility and control to your GraphQL queries.
Why is Deep Filtering important?
Well, it solves the frequent problem of filtering records containing specific content within their Modular Content and Structured Text fields. Both fields allow dynamic and repeatable structures — we call those structures blocks, and with Deep Filtering, you can now easily retrieve records that meet specific criteria within nested blocks.
This capability opens up new possibilities for organizing and querying your data. Whether you're building a blog with various content elements or an e-commerce site with products and related information, Deep Filtering provides a streamlined way to access the exact data you need without unnecessary additional API calls slowing down the final response time to the user.
How does it work?
Suppose you have a page
model with a content
Modular Content field that accepts a product
block. In one section of the website, you need to retrieve all the pages that contain a product
block with a name equal to "T-Shirt"
, and a price greater than 30.
The first step is to edit the content
field and enable the Deep Filtering option for it. Deep Filtering needs to be explicitly enabled on a per-field basis to avoid complicating — and therefore slowing down — your GraphQL schema by generating many types that will never actually be used.
Once enabled, you can use the following GraphQL query and get back the desired result:
query {allPages(filter: {content: {any: { product: { name: { eq: "T-Shirt" }, price: { gt: 30 } } }}}) {# ...}}
This is just a simple example of what you can achieve with Deep Filtering: in our documentation page you can find many more use cases, like being able to apply logical OR conditions, filtering records containing at least one block of a specific type, or of any kind.
Read the full documentationPublic beta and call for feedback
Update: As of 2024, Deep Filtering is officially released and no longer in beta! Please see our docs for usage guidelines or this newer blog post for a detailed walkthrough.
We have released Deep Filtering in public beta so that you can try it out and see if it meets your needs. We will collect feedback over the next month and make any necessary changes before releasing a final version.
We strongly encourage you to give Deep Filtering a try in a sandbox environment, and send any feedback or issues to support@datocms.com. Happy filtering!