Do you mean when querying?
With the schema as mentioned before you could do something like this:
query {
queryVideo {
container {
__typename # Will tell you if the container is a Commercial or Promotion
... on Commercial {
id
name
}
... on Promotion {
id
name
}
}
}
}
Alternatively you could put the id (and name) into the interface as well, would probably fit your case better:
interface VideoContainer {
id: ID!
name: String!
video: Video
}
type Commercial implements VideoContainer {
commercialProperty: String!
}
type Promotion implements VideoContainer {
promotionProperty: String!
}
type Video {
id: ID!
url: String!
container: VideoContainer @hasInverse(field: video)
}
And query like this
query {
queryVideo {
id
url
container {
id
name
__typename # Will tell you if the container is a Commercial or Promotion
... on Commercial {
commercialProperty # Here you could extract Commercial only predicates
}
... on Promotion {
promotionProperty # Here you could extract Promotion only predicates
}
}
}
}