Using filters
#Overview
Filtering allows you to restrict the content shown by specific parameters. This is helpful when trying to create a more curated overview of content.
Hygraph does not currently support filtering for Rich Text (even if inside components), JSON, multi-value fields, colors, or coordinates.
These filters can be useful when building content views, looking for a specific type of content, or finding content that matches several parameters, such as "Created by
a certain user & Stage
published".
#Quick Filters
Our Quick Filters feature reduces the time and effort required to create a filter. Editors can now find the content they need, faster.
Quick Filters
It offers several predefined filters that apply instantly when selected, allowing editors to focus on their work without unnecessary distractions.
Quick Filters are available in both regular content views and asset views.
To add Quick Filters, simply use the Filter
menu to display the available options and select one.
Add a Quick Filter
Once you select a Quick Filter, the regular filter appears in the filter bar and the content table is sorted accordingly.
You can apply more than one Quick Filter. To do this, simply use the filter menu again and select another one.
For instance, the following image shows a content table where two Quick Filters have been applied, Created by me
& Only published entries
:
Quick Filter applied
Quick filters are commonly used filter configurations that offer a shortcut to finding the content you're looking for. Once applied, you can use them as they are, or edit them.
#Column filters
The Filter
menu also contains column filters.
Column filters
Column filters allow you to filter content by some system and custom fields, stage and ID.
Quick and column filters function in the same way. The following document section explains how to use them.
#Adjust filters manually
You can find the filters on any content view, at the top of the content table. If there are no filters added, this is how it will look like:
Filter Bar
To apply filters:
- Navigate to the Content Editor & select a view from the collapsible sidebar.
- Click the
Filter
button at the top of the content table. - Select one of the fields listed for filtering. It can be a quick or column filter.
- If you selected a quick filter, the results will show on the table below.
- If you selected a column filter, you need to configure it:
- Select a condition. This document section explains what each condition does.
- Enter a comparison value in the input to the right of the filter method.
You can use the Search
at the top of the filters menu to quickly find a filter.
For example, the following image shows that we have selected to filter by ID
, then selected the condition contains
, and finally we typed "002" in the input. As a result, the filter shows all entries that have an ID containing 002:
Filter example
To remove a filter, simply click the X
button next to it.
Remove filter
#Filtering by entry
After applying a quick or column filter, the results will display on the table below. The following example shows the Created By
filter applied:
"Created By" filter applied
You can adjust these filters manually by using the input fields or dropdown menus, and you can add additional filters by clicking on the filter icon.
Apply a Filter
Additionally, you can also filter by fields that allow multiple values. Here's an example showing an enumeration field for product size:
Multi-value enum filtering
#Filtering by relations
To filter your content entries by a reference field, click the Filter
button and select the reference field from the column filters list.
It is not possible to filter by union-type reference fields - those that allow you to reference more than one model in a field.
To configure the filter:
- Select the field of this model that you want to use.
- Select a condition from the dropdown menu.
- Some conditions will require that you type in some data to filter by, such as a name or a slug.
Updated At
andCreated At
require that you select a date from a calendar and type in a time.Is null
andIs not null
do not require any additional input.
The following example filtering condition shows all
of the content entries where the "Other products" reference field links to entries with a Slug
that contains tote
.
Filtering by relations
The default reference filters that all projects have are Created by
, Updated by
, and Published by
. They are related to project users and provide relational fields that you can select from the condition dropdown.
You can also filter by custom reference fields created for your project, as long as they are not union fields.
Our Editor Guides contain detailed information all reference filters available.
#Filtering by content stage
To filter content by stage, click the Filter
button at the top of the content table, and select Stage
from the column filters list.
After this, use the dropdown menus to select a condition and stage.
Filtering by content stage
#Stages and conditions
While there are three default stages - DRAFT
, PUBLISHED
, and PUBLISHED (!)
- stages other than the default ones can exist in the projects of Growth and Enterprise plans.
Stage Name | Definition |
---|---|
DRAFT | Content entries that exist in DRAFT , and don't exist in any other stage. This content has never been published. |
PUBLISHED | Content entries that exist in PUBLISHED and are not outdated. This means that the published version of this content is also the latest version on the system. |
PUBLISHED (!) | Content entries that exist in PUBLISHED but are outdated. This means there is a version of this document currently published, but there is also another more recent version in the system. |
Please take into account that our stages are not linear and sequential. There are cases where content can be in more than one stage at the same time, such as PUBLISHED and QA. This would happen if, for instance, you edit an already published document, but select the QA stage from the dropdown upon publishing your changes.
Condition | Definition |
---|---|
is | Select this condition to fetch content entries that only exist in the selected stage. |
is not | Select this condition to fetch content entries that do not exist in the selected stage, and only exist in one stage. |
contains | Select this condition to fetch content entries that exist in the selected stage, irrespective of also existing in other stages. This condition will only display for projects with more than two stages. |
doesn't contain | Select this condition to fetch content entries that don't exist in the selected stage, irrespective of also existing in other stages. This condition will only display for projects with more than two stages. |
Filtering can also be applied to your project's custom filters.
Custom filters creation will result in a state that can be updated or outdated, and the behavior will be the same as the updated/outdated behavior shown above for PUBLISHED
and PUBLISHED (Outdated)
.
#Filtering conditions
The following list explains basic conditions and what they do:
Option | Description |
---|---|
Is | Exact match |
Is Null | Matches empty (without content) |
Is Not Null | Matches not null (with any content added) |
Is Not | Exclusion match |
Less Than | for numeric fields (including date and dateTime) |
Less Than or Equal To | for numeric fields (including date and dateTime) |
Greater Than | for numeric fields (including date and dateTime) |
Greater Than or Equal To | for numeric fields (including date and dateTime) |
Contains | String search |
Doesn't Contain | Exclusion by string search |
Starts With | Starting string match |
Doesn't Start With | Exclusion by starting string match |
Ends With | Ending string match |
Doesn't End With | Exclusion by ending string match |
Includes some | for multi-value fields, some of the provided values match |
Includes all | for multi-value fields, all of the provided values match |
Includes none | for multi-value fields, none of the provided values match |