Deep Inheritance (via type and interface)

Hi I’m new to dgrap and graphql

I want to reproduce an already existing object schema that contains deep inheritance.
I was wondering if this is possible ?

I explain : I have type tree like A ← B ← C . I have 3 levels of inheritance.

Can we do that with dgraph ?

Thank you

Yes

@amaster507 I try both possibilities

interface TextObject {
id: ID!
text: String
}

type Post implements TextObject{
datePublished: DateTime
}

type Question implements Post {
title: String!
}

and

interface TextObject {
id: ID!
text: String
}

interface implements TextObject{
datePublished: DateTime
}

type Question implements Post {
title: String!
}

with no success , what is the graphql to achieve this ?

thank you

I just now noticed I misunderstood the OP. You are needing to deep inheritance on interfaces. I read it the first time as deep inheritance on nodes with edges. Sorry about that.

You should be able to inherit from multiple interfaces but an interface cannot implement another interface, nor can a type implement another type. So here is a possible solution:

interface TextObject {
  id: ID!
  text: String
}
interface IPost{
  datePublished: DateTime
}
type Post implements TextObject & IPost {
  # have to have at least one field here
}
type Question implements TextObject & IPost {
  title: String!
}

In your solution I only have 2 levels.
L1: TextObject and IPost
L2: Post and Question
Infortunately it does not work …

I think I’ll create an issue to allow inheritance between interfaces as well

Just FYI, the GraphQL specification https://spec.graphql.org/ does not support interfaces implementing other interfaces in the latest (2018) release. It is in the draft for the next release though. This will probably be a blocker to get the specification published before this gets implemented by Dgraph.

Thank you @amaster507,
I will have to break the object model to achieve this

I will follow the status of the new specs.

Do you think it worth creating an issue to track this ?