> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sqd.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Interfaces

> Define queryable GraphQL interfaces schema files — share fields across entity types and run polymorphic queries via OpenReader.

The schema file supports [GraphQL Interfaces](https://graphql.org/learn/schema/#interfaces) for modelling complex types sharing common traits. Interfaces are annotated with `@query` at the type level and do not affect the database schema, only enriching the GraphQL API queries with [inline fragments](https://graphql.org/learn/queries/#inline-fragments).

Currently, only [OpenReader](/en/sdk/squid-sdk/reference/openreader-server) supports GraphQL interfaces defined in the schema file.

### Examples

```graphql theme={"system"}
interface MyEntity @query {
  id: ID!
  name: String
  ref: Ref
}

type Ref @entity {
  id: ID!
  name: String
  foo: Foo! @unique
  bar: Bar! @unique
} 

type Foo implements MyEntity @entity {
  id: ID!
  name: String
  ref: Ref @derivedFrom(field: "foo")
  foo: Int
}

type Bar implements MyEntity @entity {
  id: ID!
  name: String
  ref: Ref @derivedFrom(field: "bar")
  bar: Int
}

type Baz implements MyEntity @entity {
  id: ID!
  name: String
  ref: Ref
  baz: Int
}
```

The `MyEntity` interface above enables `myEntities` and `myEntitiesConnection` [GraphQL API queries](/en/sdk/squid-sdk/reference/openreader-server/api) with inline fragments and the `_type`, `__typename` [meta fields](https://graphql.org/learn/queries/#meta-fields):

```graphql theme={"system"}
query {
  myEntities(orderBy: [_type_DESC, id_ASC]) {
    id
    name
    ref {
        id
        name
    }
    __typename
    ... on Foo { foo }
    ... on Bar { bar }
    ... on Baz { baz }
  }
}
```
