# Define @count directive in GraphQL schema

**URL:** <https://discuss.dgraph.io/t/define-count-directive-in-graphql-schema/15616>\
**Category:** GraphQL\
**Tags:** kind:question\
**Created:** [September 19, 2021, 8:14pm UTC](https://discuss.dgraph.io/t/define-count-directive-in-graphql-schema/15616 "2021-09-19T20:14:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ihassanyousaf](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/ihassanyousaf/32/8885_2.png) [@ihassanyousaf](https://discuss.dgraph.io/u/ihassanyousaf)\
**Post date:** [September 19, 2021, 8:14pm UTC](https://discuss.dgraph.io/t/define-count-directive-in-graphql-schema/15616/1 "2021-09-19T20:14:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![amaster507](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/amaster507/32/4123_2.png) [@amaster507](https://discuss.dgraph.io/u/amaster507)\
**Post date:** [September 20, 2021, 1:21am UTC](https://discuss.dgraph.io/t/define-count-directive-in-graphql-schema/15616/2 "2021-09-20T01:21:27Z")

</div>

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

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

```

Generates the schema to do:

```auto
query {
  querySomeType {
    id
    connected_edgesAggregate {
      count
    }
  }
}

```
