I have a document with the following contents:
{
"data": {
"posts": [
{
"id": "5d9f1af799785458ed55fcf3",
"title": "Lorem ipsum dolor sit amet, consectetuer adipiscing eli",
"likedBy": {
"readers": [
"abc",
"xyz",
"mnp"
]
}
},
{
"id": "5d9f2afa9cf1b45a20edaf93",
"title": "Sed ut perspiciatis unde omnis iste natus error sit volupt",
"likedBy": null
},
{
"id": "5d9f2d1cd12ce45b11e90920",
"title": "But I must explain to you how all this mistaken idea of deno",
"likedBy": null
}
]
}
}
Here, I have a field likedBy which is an object with an array as its value.
Now, I can run the following query to retrieve all documents:
{
posts{
id
title
likedBy
}
}
However, is there any way to filter out specific values of the array at the query level? For instance, Say I want my output to look like this:
{
"data": {
"posts": [
{
"id": "5d9f1af799785458ed55fcf3",
"title": "Lorem ipsum dolor sit amet, consectetuer adipiscing eli",
"likedBy": {
"readers": [
"abc",
]
}
},
{
"id": "5d9f2afa9cf1b45a20edaf93",
"title": "Sed ut perspiciatis unde omnis iste natus error sit volupt",
"likedBy": null
},
{
"id": "5d9f2d1cd12ce45b11e90920",
"title": "But I must explain to you how all this mistaken idea of deno",
"likedBy": null
}
]
}
}
Here, I have returned all documents as before, except with only abc in the likedBy array. Is that possible with GraphQL?