indexer-schema

Defines and validates schema.graphql entity types, directives, and relationships for HyperIndex indexers.

546|55|Updated May 24, 2024
One-click install
npx skills add https://github.com/enviodev/hyperindex --skill indexer-schema
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: indexer-schema
Source: https://github.com/enviodev/hyperindex/tree/main/packages/cli/templates/static/shared/.claude/skills/indexer-schema
Command: npx skills add https://github.com/enviodev/hyperindex --skill indexer-schema

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing a correct schema.graphql for a HyperIndex indexer requires knowing Envio-specific rules that differ from The Graph and other frameworks, such as entity references without _id suffixes, @derivedFrom semantics, and array restrictions. This Skill encodes those rules so schema definitions pass codegen on the first attempt.

Core Features & Use Cases

  • Entity and Scalar Reference: Covers ID requirements, naming rules, and the full scalar-to-TypeScript type mapping including BigInt, BigDecimal, Bytes, and Timestamp.
  • Directive Guidance: Explains @derivedFrom reverse lookups, @index single and composite indexes, and @config precision settings with correct syntax and common pitfalls.
  • Schema-to-Handler Mapping: Documents how codegen transforms entity reference fields into _id-suffixed TypeScript handler fields.
  • Use Case: When adding a Swap entity linked to a Pool, use this Skill to write pool: Pool! in the schema, set pool_id in the handler, and expose swaps: [Swap!]! @derivedFrom(field: "pool") without triggering codegen errors.

Quick Start

Ask the AI to define or review a schema.graphql for your Envio indexer, for example to add a new entity with relationships and indexes.

Frequently Asked Questions about indexer-schema

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I define entity relationships in a HyperIndex schema.graphql?

Reference the entity type directly in the schema field, such as `pool: Pool!`, never using an _id suffix. Codegen then exposes `pool_id` in TypeScript handlers, typed as the referenced entity's id.

How does @derivedFrom work in Envio indexer schemas?

@derivedFrom creates a virtual reverse-lookup field queryable only through the API, not in handlers. Its field argument must match the child entity's schema field name, such as @derivedFrom(field: "pool") matching Swap.pool.

What scalar types does HyperIndex schema.graphql support?

Supported scalars include ID, String, Int, Float, Boolean, BigInt, BigDecimal, Bytes, Timestamp, and Json. BigInt and BigDecimal accept @config precision and scale settings, with defaults of 76 digits precision.

Why does my schema fail codegen with an array field?

Only non-nullable arrays of non-nullable elements like [Type!]! are supported; nullable elements, nested arrays, and [Boolean!]! or [Timestamp!]! are rejected. Entity arrays also require @derivedFrom, otherwise codegen errors.

When should I use @index on schema fields?

Use @index on fields frequently filtered in queries, such as addresses or timestamps, and composite @index(fields: [...]) for multi-field ordering. Indexes build after backfill completes, or on demand when a getWhere query needs one.