I need to use both GraphQL schema and apply RDF @reverse directive on some fields. The issue is that if the GraphQL schema is reapplied, reverse relations on those fields get deleted.
I see a way to get around it by modifying GraphQL schema fields with @dgraph directive, as described in 7336; however, it is not currently possible to use this solution on union types. Example:
<Object.owner>: uid @reverse .
type Object {
owner: Person @dgraph(pred: "Object.owner")
}
type BusinessMan {
companyName: String
owns: [Object] @dgraph(pred: "~Object.owner")
}
type AnotherPersonType {
owns: [Object] @dgraph(pred: "~Object.owner")
}
union Person = BusinessMan | AnotherPersonType
This errors:
couldn't rewrite mutation updateGQLSchema because input:1: Type Object; Field owner: should be of type BusinessMan to be compatible with @dgraph reverse directive but is of type Person.\n
I see that the same issue but with interfaces has been fixed; would it be possible to also allow such dgraph directives on union types?
Thank you Poorshad!
Yes, making it possible to not override @reverse after GraphQL schema is applied would be ideal. Your solution (applying DQL migration each time after GraphQL runs) is very similar to the workaround we’re currently using, but it has some of its own issues.