[Bug] Allow type to implement interfaces with same fields

Schema:

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:

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!

1 Like

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

J

Thats my point - dgraph seems to derive a type:

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

which it shouldn’t.

1 Like

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

@MichelDiz - Probably a bug?

J

1 Like

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?

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.

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?

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.