Entities Schema (schema.graphql)
The schema.graphql file defines the data model for your HyperIndex indexer. Each entity type defined in this schema corresponds directly to a database table, with your event handlers responsible for creating and updating the records. HyperIndex automatically generates a GraphQL API based on these entity types, allowing easy access to the indexed data.
Defining Entity Types
Entities in your schema are defined as GraphQL object types:
Example:
type User {
id: ID!
greetings: [String!]!
latestGreeting: String!
numberOfGreetings: Int!
}
Requirements:
- Every entity must have a unique
idfield, using one of these scalar types:ID!,String!,Int!, orBigInt!
- The
idfield must be non-nullable, must not be a list, and cannot be a@derivedFromfield. - There is no
@entitydirective: everytypein the file is an entity. - An entity name is at most 63 characters. Two entities can't share a name that differs only in the case of its first letter (
userandUser), and an entity and an enum can't share a name. - Entity names, enum names and enum values can't be
enumor a built-inObject.prototypeproperty name such asconstructor,toString,valueOf,hasOwnPropertyor__proto__.envio codegenrejects them withSchema contains the following reserved keywords: ....