How to add reverse directive

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!

Hi Vibin,
In GraphQL schema, you would need to use the hasInverse directive to achieve the reverse traversal. Please see the example here.

1 Like

Hi Anand,

Thanks for your response :smiley:

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!

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.