Using the @cascade directive on query directly against dgraph’s GrapgQL endpoint works fine and prunes the results:
query {
queryAnime(first: 10) @cascade {
id
names {
localization (filter:{
id: {eq:"UNDEFINED"}
}){
id
}
text (filter: {string: {alloftext:"秦时明月 特别篇: 空山鸟语"}}){
string
}
}
}
}
=>
{
"data": {
"queryAnime": [
{
"id": "XL84UE",
"names": [
{
"localization": {
"id": "UNDEFINED"
},
"text": {
"string": "秦时明月 特别篇: 空山鸟语"
}
}
]
}
]
},
"extensions": {
"touched_uids": 247,
"tracing": {
"version": 1,
"startTime": "2020-08-11T13:33:11.405041351Z",
"endTime": "2020-08-11T13:33:11.628524341Z",
"duration": 223483047,
"execution": {
"resolvers": [
{
"path": [
"queryAnime"
],
"parentType": "Query",
"fieldName": "queryAnime",
"returnType": "[Anime]",
"startOffset": 135443,
"duration": 223312664,
"dgraph": [
{
"label": "query",
"startOffset": 204417,
"duration": 222921243
}
]
}
]
}
}
}
}
but once dgraph is wrapped by an Apollo Server (using this guide), the directives stops to works:
{
"data": {
"queryAnime": [
{
"id": "XL84UE",
"names": [
null,
null,
null,
null,
{
"localization": {
"id": "UNDEFINED"
},
"text": {
"string": "秦时明月 特别篇: 空山鸟语"
}
},
null
]
},
{
"id": "UJKQZ3",
"names": [
null,
null,
null,
null,
null,
null
]
},
{
"id": "M3O5HL",
"names": [
null,
null,
null,
null,
null,
null
]
},
{
"id": "ZC1XA1",
"names": [
null,
null,
null,
null,
null,
null
]
},
{
"id": "K4P8OG",
"names": [
null,
null,
null,
null,
null,
null
]
},
{
"id": "ISJJ6K",
"names": [
null,
null,
null,
null,
null,
null
]
},
{
"id": "0467PM",
"names": [
null,
null,
null,
null,
null,
null
]
},
{
"id": "46KC6K",
"names": [
null,
null,
null,
null,
null,
null
]
},
{
"id": "OC16NE",
"names": [
null,
null,
null,
null,
null
]
},
{
"id": "7BFSRI",
"names": [
null,
null,
null,
null,
null,
null
]
}
]
}
}
I couldn’t find anything about delegation of directives on the apollo doc nor graphql-tool doc, and the dgraph page which lists the directives is still incomplete so I couldn’t find any solution / explanation.
Is that a bug or is it a misconfiguration of the Apollo server?
I would point out that this behaviour occurs only when the directive is used on query, using it on fields works perfectly