Implement 2 interfaces

Hi,

What will happen if two interfaces have the same fields for example

enum Color{
   Blue
   Green
   Brown
   Gray
   Balck
}
interface IFish{
    id: ID!
    eyesColor: Color
}
interface IBird{
    id: ID!
    eyesColor: Color
}
type Penguin implements IFish & IBird{
    legsNumber: Int!
}

Thanks,
Or

1 Like

Interesting question - I’d like to know the answer too. However it seems to me the immediate problem could be solved by putting legsNumber under IBird and have Penguin implement both IFish and IBird with no fields under it.

(a penguin is a bird and not a fish in real life…)

Thanks for your response,

The types are not part of a real use case.
I just wanted to clarify my question by showing an example.

Anyway do you know who can have the answer?

Bets,
Or

Syntactically, that is correct. GraphQL spec allows that behavior.
But unfortunately, we haven’t yet handled this case in our implementation. Thanks for bringing this to our notice.

Marking it as a bug for now.

@abhimanyusinghgaur any news about it?

This is something that we’ll look into after the 20.11 release is done. I can’t give you an ETA for this right now. If other folks are running into this issue, please let us know.

Hi @spinelsun, We added support to repeat the field name of ID type. You can now have field of ID type and of same name in multiple implementing interfaces.This fix is currently avaliable in master branch and will also be avaliable in 20.11 release.
PR:fix(GraphQL): This PR allows repetition of fields inside implementing type which are present in interface and also allow to inherit field of same name of type ID from multiple interfaces. by JatinDevDG · Pull Request #7053 · dgraph-io/dgraph · GitHub