Ah, sorry, so you want the drag-and-drop ordering on the Posts themselves, not the Feature Groups? That might be harder then, you’re right Apologies for misunderstanding.
As a (imperfect) workaround, here’s a couple ways to avoid having to write two queries:
Workaround #1:
Not sure if you knew this already, but in GraphQL, you can actually make several requests inside the same query, one after another, inside the same API call. They come back at the same time. For example:
query MyQuery {
allFeatureGroups(filter: {showThisFeatureGroup: {eq: true}}) {
id
name
posts {
id
title
}
}
onlyShowThesePosts:allPosts (filter: {showThisPost: {eq: true}}) {
id
}
}
Will get you:
{
"data": {
"allFeatureGroups": [...], // The groups and all posts, in order
"onlyShowThesePosts": [ // You can then filter on the clientside against this list
{
"id": "SnrOC9D_RveJUXYpKrCijw"
},
{
"id": "BoOgw50NSwiRujnm3dW2ew"
},
{
"id": "Sw-qh6TrRYC0JoGty24iMA"
},
{
"id": "PIuUHuJ_Qaq1WJzprf2jfQ"
}
]
}
}
Although it’s two separate GraphQL statements, it’s still just one API call and the client gets both at the same time, and then you can then filter allFeatureGroups
against onlyShowThesePosts
without having to make a separate call.
Or Workaround #2:
You can of course also just include the Post fields to filter by inside the query, and do all the filtering clientside, like:
query MyQuery {
allFeatureGroups(filter: {showThisFeatureGroup: {eq: true}}) {
id
name
posts {
id
title
showThisPost
}
}
}
Which becomes:
{
"data": {
"allFeatureGroups": [
{
"id": "F9xRzJmIQ52Zb6xmW0gTVA",
"name": "Top 10 Lists",
"posts": [
{
"id": "GNUv20kdQtOslxxzVyaWQw",
"title": "This post should be hidden",
"showThisPost": false
},
{
"id": "Sw-qh6TrRYC0JoGty24iMA",
"title": "Top 10 Mistakes Humans Make",
"showThisPost": true
},
{
"id": "BoOgw50NSwiRujnm3dW2ew",
"title": "Ten Jamstack Examples",
"showThisPost": true
}
]
},
{
"id": "OT0M7wMDRPGxmiwSsEbgvA",
"name": "Case Studies",
"posts": [
{
"id": "BoOgw50NSwiRujnm3dW2ew",
"title": "Ten Jamstack Examples",
"showThisPost": true
},
{
"id": "GNUv20kdQtOslxxzVyaWQw",
"title": "This post should be hidden",
"showThisPost": false
}
]
},
{
"id": "QjPvquQeRvWwRm_6UPD15A",
"name": "How-To Guides",
"posts": [
{
"id": "SnrOC9D_RveJUXYpKrCijw",
"title": "How to use a headless CMS",
"showThisPost": true
},
{
"id": "PIuUHuJ_Qaq1WJzprf2jfQ",
"title": "How to change your schema",
"showThisPost": true
},
{
"id": "GNUv20kdQtOslxxzVyaWQw",
"title": "This post should be hidden",
"showThisPost": false
}
]
}
]
}
}
Then in JS you can filter out all the posts[]
that have showThisPost != true
. Yes, that results in a bit of over-fetching, but it should have a minimal performance impact. To your editors it should still work the same, but you just move the filtering logic clientside instead of in GraphQL.
I know neither solution is perfect, though, and I appreciate you illustrating the use case here. Let’s also leave this thread open as a feature request (assuming that is what you meant to post it as) and hope for a better official solution someday. (I agree, being able to apply filters on an array field would be nice). Please remember to vote on the topic at the top (the little blue Vote button)