Today, I had a very interesting feedback call and one request was to filter by references, e.g.
“Give me all blogs where the category is published and title starts with XYZ”
Contentful has the same feature, but I don’t like the syntax: https://www.contentful.com/developers/docs/concepts/relational-queries/
It is very simple, but also very limited and you have a a lot of issues to validate such a query, because the model would be huge.
My idea would be to allow subqueries, this is something that would probably only work with json queries (So we have to add this to graphql), but the query would look like this:
{
"path": "data/references/iv",
"op": "eq",
"value": {
"filter": {
"and": [{
"path": "status",
"op": "eq",
"value": "Published
}, {
"path": "data/title/iv",
"op": "startsWith",
"value": "XYZ"
}]
},
"type": "schema" // Optional
}
}
We could also introduce a general improvement and make the op optional, then it would look like this
{
"path": "data/references/iv",
"value": {
"filter": {
"and": [{
"path": "status",
"value": "Published
}, {
"path": "data/title/iv",
"op": "startsWith",
"value": "XYZ"
}]
},
"type": "schema"
}
}
The advantage is
I have a few questions:
- Does it make sense for you?
- Would you prefer another syntax?
- Would we need other operators for that as well?