subsquid / squid-sdk

The main repo of the squid SDK
Apache License 2.0
1.23k stars 151 forks source link

Queryable interfaces #115

Closed eldargab closed 2 years ago

eldargab commented 2 years ago

Example usage

interface Entity @query {
  id: ID!
  name: String
}

type Foo implements Entity @entity {
  id: ID!
  name: String
  foo: Int
}

type Bar implements Entity @entity {
  id: ID!
  name: String
  bar: Int
}

query {
  entities {
    id
    name
    ... on Foo {
      foo
    }
    ... on Bar {
      bar
    }
  }
}
belopash commented 2 years ago

Is there something like "type" to identify what entity it is?

eldargab commented 2 years ago

Standard __typename works. To sort by entity type use orderBy: _type_ASC