This is how the GraphQL spec defines interfaces:
interface NamedEntity {
name: String
}
type Person implements NamedEntity {
name: String
age: Int
}
Notice how the name
field is repeated in the type implementing the interface. Not doing so is an error. In Dgraph, however, we omit the repeated field:
interface NamedEntity {
name: String
}
type Person implements NamedEntity {
age: Int
}
At first, this doesn’t come across as a major problem - I personally found it redundant to specify the field names twice. However, besides not being compliant, it causes another issue. Take the following example:
interface Fruit {
id: ID!
price: Int!
}
type Apple implements Fruit {
id: ID!
price: Int!
color: String!
}
type Banana implements Fruit {
id: ID!
price: Int!
}
Notice how Banana
doesn’t have any extra fields - the only difference is the type. This should be valid GraphQL, however, since we don’t repeat field names in the type with Dgraph, it errors out, because the type definition of Banana
is now empty.