Define @count directive in GraphQL schema

Hi,

I have been migrating my DQL schema to GraphQL schema but having difficulty in define @count directive in the schema.

E.g : In DQL let’s say I have a predicate connected_edges which is of type [uid] . if I want to introduce inverse and count it is easy. i-e connected_edges: [uid] @inverse @count .

now I am trying to replicate the same thing in GraphQL but unable to do that.

E.g I have graphQL predicate connected_edges: [SomeType] @dgraph(pred: "SomeType.connected_edges") the @dgraph directive gives me liberty to connect the DQL predicate with GQL but there is no way I can define a @count directive there as well. I have to manually add @count directive whenever I update the Schema.

Is there any approach of adding @count directive in GraphQL as it is in DQL?

Thanks

Look at the generated GraphQL schema and you will find that every field to an edge (another type) auto generates an additional aggregate field.

type SomeType {
  id: ID
  connected_edges: [SomeType]
}

Generates the schema to do:

query {
  querySomeType {
    id
    connected_edgesAggregate {
      count
    }
  }
}
1 Like