Cascade directive not properly working on fragments if types have the same field names

Hi @Luscha, Nice catch !!Preformatted text
The reason for this is the way cascade work in dgraph and graphql. Currrently all the filtering of objects related to @cascade is done in dgraph only and in graphql we filter result on basis of what’s been asked in query.So according to it , it’s expected behaviour. Note that field name is present in both types Movie and Comic.

As we are querying on Meta, we will get all the objects which implemented Meta and in this case, we will get both. But since we have asked to expand object of type Movie only , we get the other one empty. See the below graphql and the generated dgraph query.

GraphQL

query {
   queryMeta(first:2) @cascade{
       ... on Movie {
           names
       }
   }
}

Dgraph

query {
  queryMeta(func: type(Meta), first: 2) @cascade {
    dgraph.type
    names : Generic.names
    dgraph.uid : uid
  }
}

For the second case we have asked for field rating and only object of type “Movie” have it, So we don’t get any extra empty result because that is already filtered by cascade in dgraph.