How to return the facets in shortest path query when the predicate has more than 2 facets

Below is graphql:

{
     path as shortest(from 0x7, to:0x3, depth:6, numpaths:50){
          friends @facets 
     }
     all (func:uid(path)){
          name 
     }
}

Below is the mutation:

{ 
    set{
           _:alice <friend> _:bos (close=true, relative=false) .
     }
}

The error message is : Expected 1 but got 2 facets;

I didi research on dgraph website and found beolow one line:
Only one facet per predicate in the shortest query block is allowed.

I am not sure if it is the answer. If it is the answer, is there any solution to fix it.

Thank you very much for your response!

Hey @doushubao1984, welcome to the Dgraph community.

Yes, this is the current implementation. You can use 2 queries one for each of the facets, like @facets(close) in 1 query and @facets(relative) in another. And then aggregate the result later.

Hi Naman,

Thank you very much for reply!
Could you tell me how to aggregate the two query in one request?

Thanks a lot.

Hi @doushubao1984, as only one shortest path query is allowed in a query block. The aggregation can’t be done within the query and has to be done at client end.

1 Like

I see. Thanks a lot! Naman.

1 Like