# How to add reverse directive

**URL:** <https://discuss.dgraph.io/t/how-to-add-reverse-directive/15110>\
**Category:** Dgraph\
**Tags:** schema, dgraph\
**Created:** [July 28, 2021, 3:59am UTC](https://discuss.dgraph.io/t/how-to-add-reverse-directive/15110 "2021-07-28T03:59:30Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![iamvibinvijay](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/iamvibinvijay/32/8609_2.png) [@iamvibinvijay](https://discuss.dgraph.io/u/iamvibinvijay)\
**Post date:** [July 28, 2021, 3:59am UTC](https://discuss.dgraph.io/t/how-to-add-reverse-directive/15110/1 "2021-07-28T03:59:30Z")

</div>

Hi All,

Could you please help me in adding the reverse edge for the attributes userlist.userSkills and skills.belongsTo ?  
As of now, I’m using curl to load this schema and through the Ratel UI, I’m manually adding the reverse edge for the predicates.

type userlist {  
username: String! @search(by:[fulltext,term])  
publicId: String! @search(by:[fulltext,term])  
userSkills: [skills]  
}

type skills {  
skillPublicId: String! @search(by:[fulltext,term])  
skillName: String! @search(by:[fulltext,term])  
belongsTo: [skills]  
}

I tried adding the @reverse in the schema file but I’m getting this error while loading it using CURL,  
{“errors”:[{“message”:“resolving updateGQLSchema failed because input:3: Undefined directive reverse.\n (Locations: [{Line: 3, Column: 4}])”,“extensions”:{“code”:“Error”}}]}

Thanks!

---

<div class="post-metadata">

**Author:** ![anand](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anand/32/5674_2.png) [@anand](https://discuss.dgraph.io/u/anand)\
**Post date:** [July 28, 2021, 7:24am UTC](https://discuss.dgraph.io/t/how-to-add-reverse-directive/15110/2 "2021-07-28T07:24:09Z")

</div>

Hi Vibin,  
In GraphQL schema, you would need to use the `hasInverse` directive to achieve the reverse traversal. Please see the example [here](https://dgraph.io/docs/graphql/schema/graph-links/#two-way-edges---edges-with-an-inverse).

---

<div class="post-metadata">

**Author:** ![iamvibinvijay](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/iamvibinvijay/32/8609_2.png) [@iamvibinvijay](https://discuss.dgraph.io/u/iamvibinvijay)\
**Post date:** [August 12, 2021, 5:00am UTC](https://discuss.dgraph.io/t/how-to-add-reverse-directive/15110/3 "2021-08-12T05:00:06Z")

</div>

Hi Anand,

Thanks for your response 😃

However, when I use @hasinverse directive, I’m getting this error.

{“errors”:[{“message”:“resolving updateGQLSchema failed because input:21: Type skills; Field skillPublicId: Field skillPublicId is of type String, but @hasInverse directive only applies to fields with object types.\n (Locations: [{Line: 3, Column: 4}])”,“extensions”:{“code”:“Error”}}]}

Any idea how can I resolve this?

Thanks!

---

<div class="post-metadata">

**Author:** ![anand](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anand/32/5674_2.png) [@anand](https://discuss.dgraph.io/u/anand)\
**Post date:** [August 12, 2021, 5:05am UTC](https://discuss.dgraph.io/t/how-to-add-reverse-directive/15110/4 "2021-08-12T05:05:00Z")

</div>

Hi Vibin,  
It looks like you are trying to set a `hasInverse` on a String field. This directive can only be applied on Object types like an `Author` or a `Post`. Please review the example I had shared. If you still face issues, please share the schema you are trying to use.
