description |
---|
Learn how to filter query results using GraphQL with TerminusDB and TerminusCMS |
{% hint style="info" %} To use this How-To, first clone the Star Wars demo into your team on TerminusCMS. You will then have full access to the data needed for this tutorial {% endhint %}
Once you have Star Wars, you can enter the data product and you can type the following in the GraphQL query panel:
Let's choose homeworld
query{
People(filter: { label : { █ }}){
}
}
Type Ctrl-c
and you'll be given some filters which can be used to constrain the label field.
Let's choose a regex which demonstrates the fondness the creators of Star Wars had for the 'oo' sound.
query{
People(filter:{ label : {regex: ".*oo.*"}}){
label
homeworld{
label
}
}
}
This results in:
{
"data": {
"People": [
{
"label": "Roos Tarpals",
"homeworld": {
"label": "Naboo"
}
},
{
"label": "Yarael Poof",
"homeworld": {
"label": "Quermia"
}
},
{
"label": "Plo Koon",
"homeworld": {
"label": "Dorin"
}
},
{
"label": "Dooku",
"homeworld": {
"label": "Serenno"
}
},
{
"label": "Sly Moore",
"homeworld": {
"label": "Umbara"
}
}
]
}
}
For more sophisticated filtering, see Advanced filtering.