> For the complete documentation index, see [llms.txt](https://docs.checkpoint.snapshot.box/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.checkpoint.snapshot.box/core-concepts/entity-schema.md).

# Entity schema

Checkpoint requires a set of defined GraphQL Schema Objects. The schema objects will be used to create a database structure for indexing this data and also generating GraphQL Queries for accessing the indexed data.

In Checkpoint terms, these schema objects are called `Entities`, an Entity can be defined as a GraphQL Object with a unique name and an `id` field.

For example:

```graphql
""" Vote is a valid entity """
type Vote {
  id: String!
  voter: User
  space: String
  proposal: Int
  choice: Int
  vp: Int
  created: Int
}

type User {
  id: String!
  vote_count: Int
  created: Int
}
```

`Vote` and `User` are valid entities because their names are unique (within the schema) and contain an `id` field.

### Query generation

Checkpoint generates two Query fields for each of the defined entities. One for querying a single entity record by its id and the second for querying multiple records of an entity.

For example, using the earlier defined `User` entity, Checkpoint will generate two query fields like:

```graphql
type Query {
  user(id: ID): User
  users(
    first: Int
    skip: Int
    orderBy: String
    orderDirection: OrderDirection
    where: WhereUser
  ): [User]
}

type WhereUser {
  id: String
  id_in: [String]
  vote_count_gt: Int
  vote_count_gte: Int
  vote_count_lt: Int
  vote_count_lte: Int
  vote_count: Int
  vote_count_in: [Int]
  created_gt: Int
  created_gte: Int
  created_lt: Int
  created_lte: Int
  created: Int
  created_in: [Int]
}
```

Things to note:

* The name of the single record entity query is derived from the entity's name lowercased.
* The name of the multi-record entity query is derived from the entity's name lowercased with an `s` suffix.
* The generated `Where*` types fields for multi-record are derived based on original fields in the entity, and non-null values are treated a `AND` where filters when being executed against the database.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.checkpoint.snapshot.box/core-concepts/entity-schema.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
