I have a page query that returns a video playlist. Some videos have 'public' set to true, some false. For the videos that have their public field set to false, I do not want to include the URL of that video in the payload that Gatsby sends to the page because access to those videos is paid for.
Example:
export const query = graphql`
query MyQuery {
courses: allSanityCourses {
nodes {
price
name
playlist {
title
url
public
}
}
}
}
`
And the data it returns:
[
{
"price": 149,
"name": "Master VS Code",
"playlist": [
{
"title": "Intro",
"url": "https://youtu.be/qwertyuiop",
"public": true
},
{
"title": "Principles Part 1",
"url": "https://youtu.be/poiuytrewq",
"public": false
}
]
}
]
How can I prevent Gatsby from sending the second URL (which has public set to false) to the page?
I'm not sure Query Filters work as they seem to only allow filtering/removing fields based on the content of those same fields. What I need is to filter/remove the URL field based on another sibling field "public".