`graph codegen` doesn't export interfaces defined in the schema
hey @cruzdanilo - what are you looking to use the interfaces for?
@azf20 abstraction between multiple entities
@cruzdanilo yes, but codegen is to facilitate writing handlers in Assemblyscript - I am familiar with using interfaces for GraphQL queries, but do you have an example (perhaps pseudocode) of what you are looking to do in Assemblyscript? Are you looking to fetch an entity that might be one of several types (with a shared interface)?
interface BaseEntity {
id: ID!
blockNumber: Int!
contract: Bytes!
}
type Transfer implements BaseEntity @entity {
id: ID!
blockNumber: Int!
contract: Bytes!
from: Bytes!
to: Bytes!
tokenId: Int!
}
import { Bytes, ethereum } from '@graphprotocol/graph-ts';
interface BaseEntity { // this should be exported by codegen
id: string;
blockNumber: i32;
contract: Bytes;
}
export default function applyMetadata<T extends BaseEntity>(entity: T, event: ethereum.Event): T {
entity.blockNumber = event.block.number.toI32();
entity.contract = event.address;
return entity;
}
Got it, thanks! @otaviopace seems like interfaces are excluded from codegen here: https://github.com/graphprotocol/graph-cli/blob/110c90c6c026d68ce3b77b60dff1337398cbf711/src/codegen/schema.js#L43 What do you think about including them to support the use case above?
I am also facing the same issue as I am trying to do abstraction between different similar metadata.
Faced the same issue now.
Until this is implemented, would you like to add a section Unsupported GraphQL Features in your docs, and mention that interfaces are not supported?