Uniqueness for @id fields on interface

Hi @christiansmith, Welcome to the Dgraph community!!

We basically had this issue in getQuery when multiple implementations of interface uses @id field and if they have same value for that field then getQuery return error because @id fields are not unique across implementation types. So we decided to remove the @id field argument from getQuery on interfaces.

But as many users having problem with this braking change , we are now supporting it till 21.11.0 release (which will happen in November December this year) and till then mark it as deprecated in the generated schema to give users time to update their query.

We have also discussed your proposal to have @unique directive in interfaces with @id directive.
It seems like a good feature and we are thinking of having it. So, the final behaviour would be something like this

interface Profile {
  nameGlobal : String! @id @unique // This field will be unique across implementing types of interface and will be available in argument to getQuery on interface.
  nameLocal:  String! @id   //This field will be unique only in the implementing types and won't be added  in argument to getQuery on interface. 
  about: String
}

So, if you are only using @id field inside the interface and need that field inside getQuery for interface then , you will have to add @unique directive on it in future(after 21.11.0).
This is just a initial design and it may change a bit, but yeah we are looking forward to add something similar. Thanks !!

5 Likes