This is a post v1 discussion which started on Slack: https://wp-graphql.slack.com/archives/C3NM1M291/p1594650031121400
The idea is #1384 is nice to have in core but it's very WP like which makes it harder for none WP developers to gain the correct context and the different ways to filter. The long term plan would be to add a filtering system into core that is consistent no matter you're querying against. There are plenty of edge cases so it's worth having a deep and mostly long discussion about it before any implementation takes place.
Initial ideas
Filtering by taxonomy
Array of category slugs:
{
posts({
filter: {
categoryIn: [{ id: "category-b", idType: SLUG }, { id: "category-b", idType: SLUG }]
}
})
}
Single category:
{
posts({
filter: {
categoryId: { id: "category-b", idType: SLUG }
}
})
}
Complex category query:
{
posts({
filter: {
AND: [
categoryIn: [{ id: "category-b", idType: SLUG }],
categoryNotIn: [{ id: "category-a", idType: SLUG }]
]
}
})
}
By post information
A query you would probably never make but could:
{
posts({
filter: {
AND: [
idIn: [{id: 21, idType: DATABASE_ID}],
titleNotIn: [ "some title" ],
titleLike: "something",
titleNotLike: "something else",
contentContains: "some string",
]
}
})
}
Mixed queries with mixed relations
{
posts({
filter: {
OR: [
titleLike: "something",
AND: [
categoryIn: [{ id: "category-b", idType: SLUG }],
idIn: [{id: 21, idType: DATABASE_ID}, {id: "/path", idType: URI}]
],
]
}
})
}
The idea here is that you can quickly build up filter queries without requiring knowledge of how WP_Query works.
This is a post v1 discussion which started on Slack: https://wp-graphql.slack.com/archives/C3NM1M291/p1594650031121400
The idea is #1384 is nice to have in core but it's very WP like which makes it harder for none WP developers to gain the correct context and the different ways to filter. The long term plan would be to add a filtering system into core that is consistent no matter you're querying against. There are plenty of edge cases so it's worth having a deep and mostly long discussion about it before any implementation takes place.
Initial ideas
Filtering by taxonomy
Array of category slugs:
Single category:
Complex category query:
By post information
A query you would probably never make but could:
Mixed queries with mixed relations
The idea here is that you can quickly build up filter queries without requiring knowledge of how
WP_Queryworks.