# \[Bug\] Allow type to implement interfaces with same fields

**URL:** <https://discuss.dgraph.io/t/bug-allow-type-to-implement-interfaces-with-same-fields/15717>\
**Category:** GraphQL\
**Tags:** kind:bug\
**Created:** [October 4, 2021, 12:13pm UTC](https://discuss.dgraph.io/t/bug-allow-type-to-implement-interfaces-with-same-fields/15717 "2021-10-04T12:13:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![maaft](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@maaft](https://discuss.dgraph.io/u/maaft)\
**Post date:** [October 4, 2021, 12:13pm UTC](https://discuss.dgraph.io/t/bug-allow-type-to-implement-interfaces-with-same-fields/15717/1 "2021-10-04T12:13:20Z")

</div>

Schema:

```auto
interface IsBar {
   id: String! @id
}

interface IsBaz {
   id: String! @id
}

type Foo implements IsBar & IsBaz {
   value: String!
}

```

Posting this to dgraph results in following error:

```auto
resolving updateGQLSchema failed because input: Field Foo.id can only be defined once.

```

It seems that the fields from all implemented interfaces are just copied over to the implementing type.  
Instead I would expect that this will only be done when the field doesn’t exist already!

By the way, I wouldn’t need this if it would finally be possible for interfaces to [implement other interfaces!](http://discuss.hypermode.com/t/feature-request-interface-implements-interface/12978)

---

<div class="post-metadata">

**Author:** ![jdgamble555](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jdgamble555/32/7503_2.png) [@jdgamble555](https://discuss.dgraph.io/u/jdgamble555)\
**Post date:** [October 4, 2021, 2:52pm UTC](https://discuss.dgraph.io/t/bug-allow-type-to-implement-interfaces-with-same-fields/15717/2 "2021-10-04T14:52:54Z")

</div>

I think that is a graphql spec problem, as it would have more than one id, which is forbidden.

J

---

<div class="post-metadata">

**Author:** ![maaft](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@maaft](https://discuss.dgraph.io/u/maaft)\
**Post date:** [October 4, 2021, 6:49pm UTC](https://discuss.dgraph.io/t/bug-allow-type-to-implement-interfaces-with-same-fields/15717/3 "2021-10-04T18:49:48Z")

</div>

Thats my point - dgraph seems to derive a type:

```auto
type Foo {
   id: String! @id
   id: String! @id
}

```

which it shouldn’t.

---

<div class="post-metadata">

**Author:** ![jdgamble555](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jdgamble555/32/7503_2.png) [@jdgamble555](https://discuss.dgraph.io/u/jdgamble555)\
**Post date:** [October 4, 2021, 7:46pm UTC](https://discuss.dgraph.io/t/bug-allow-type-to-implement-interfaces-with-same-fields/15717/4 "2021-10-04T19:46:02Z")

</div>

Ah, good point. Should be fixed, @id can have multiple but ID can’t.

@MichelDiz - Probably a bug?

J

---

<div class="post-metadata">

**Author:** ![MichelDiz](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/micheldiz/32/11873_2.png) [@MichelDiz](https://discuss.dgraph.io/u/MichelDiz)\
**Post date:** [October 5, 2021, 1:23am UTC](https://discuss.dgraph.io/t/bug-allow-type-to-implement-interfaces-with-same-fields/15717/5 "2021-10-05T01:23:39Z")

</div>

that(the last one) looks like a bug to me. @aman-bansal @dmai ?

@maaft can you change or create a new ticket for this last one?

---

<div class="post-metadata">

**Author:** ![maaft](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@maaft](https://discuss.dgraph.io/u/maaft)\
**Post date:** [October 5, 2021, 7:52am UTC](https://discuss.dgraph.io/t/bug-allow-type-to-implement-interfaces-with-same-fields/15717/6 "2021-10-05T07:52:42Z")

</div>

> [@jdgamble555](#):
>
> Ah, good point. Should be fixed, @id can have multiple but ID can’t.

Just to be clear, @id is not the issue here.

@MichelDiz I’m not sure what you mean. Could you read again? The issue is fully explained in my first post and Jonathan did **not** discover another issue.

---

<div class="post-metadata">

**Author:** ![aman-bansal](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/aman-bansal/32/4475_2.png) [@aman-bansal](https://discuss.dgraph.io/u/aman-bansal)\
**Post date:** [October 11, 2021, 4:14pm UTC](https://discuss.dgraph.io/t/bug-allow-type-to-implement-interfaces-with-same-fields/15717/7 "2021-10-11T16:14:19Z")

</div>

Just trying to understand here, I see two issues:

1. If two interfaces defined the same field, node type should only consider one. I think this can be easily fixed.
2. What if both the interfaces have different id fields. what would be the expectation in this case ? I believe the expectation would be something like composite keys?

---

<div class="post-metadata">

**Author:** ![maaft](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@maaft](https://discuss.dgraph.io/u/maaft)\
**Post date:** [October 11, 2021, 9:36pm UTC](https://discuss.dgraph.io/t/bug-allow-type-to-implement-interfaces-with-same-fields/15717/8 "2021-10-11T21:36:37Z")

</div>

Aren’t multiple @id fields already supported without issues? Where do you see problems?

Or are you talking about multiple ID types with different names? I don’t see a use-case for this currently, so it could just be disallowed and an error could be thrown when posting the schema.
