Hi
Is there a way to map a field to more than one entity?
E.g. that’s a game post
type GamePost @entity {
id: ID!
game: Game!
}
and that’s a claim post
type ClaimPost @entity {
id: ID!
claim: Claim!
}
but a post is a post, can I don something like that
type Post @entity {
id: ID!
claim: Claim! | Game!
}
I’m assuming you mean a field that can have multiple different entity types, and yes, you can use interfaces, although the entity types you want to be able to populate that field will need to implement that interface
interface GenericInterface {
id: ID!
}
type GamePost implements GenericInterface @entity {
id: ID!
game: Game!
}
type ClaimPost implements GenericInterface @entity {
id: ID!
claim: Claim!
}
type Post @entity {
id: ID!
claim: GenericInterface!
}
Although from the entity type names it would almost seem as if you want to have a common interface between GamePost
and ClaimPost
that would be called Post
Hi,
Thanks for the response, but the idea was to only use one type of Post and have it connect with two different entities
Game’s posts & Claim’s posts.
These entities look something like so
type Game @entity {
id: ID! # contract address
posts: [GamePost!]! @derivedFrom(field: “entity”)
}
type Claim @entity {
id: ID! # contract address
posts: [ClaimPost!]! @derivedFrom(field: “entity”)
}