@zkp2p/indexer-schema
v0.1.4
Published
ZKP2P Indexer GraphQL schema
Readme
@zkp2p/indexer-schema
Exports the GraphQL schema used by the ZKP2P indexer.
Install
pnpm add @zkp2p/indexer-schemaUsage
// Load the SDL string (GraphQL schema) in Node
import { schemaSDL } from '@zkp2p/indexer-schema';
// or CommonJS: const { schemaSDL } = require('@zkp2p/indexer-schema');
// Path reference for codegen configs
schema: node_modules/@zkp2p/indexer-schema/dist/schema.graphqlNotes
- Includes: Deposit, Intent, DepositPaymentMethod, MethodCurrency.
- The file is generated at publish time from the indexer repo.
Backend Codegen Example (using domain.graphql)
This is a minimal example to generate TypeScript types from the exported domain schema.
1) Install codegen tooling
pnpm add -D @graphql-codegen/cli @graphql-codegen/typescript @graphql-codegen/typescript-operations2) Add a codegen config (codegen.yml)
schema: node_modules/@zkp2p/indexer-schema/dist/schema.graphql
# Alternatively, if using a workspace dependency:
# schema: ../zkp2p-indexer/dist/schema.graphql
generates:
src/__generated__/types.ts:
plugins:
- typescript
- typescript-operations
config:
avoidOptionals: true3) Add an npm script
"scripts": {
"codegen": "graphql-codegen --config codegen.yml"
}4) Use the generated types
- Import
Deposit,Intent, etc. operation and type definitions fromsrc/__generated__/types.ts. - If you serve GraphQL in the backend, you can build an executable schema from
domain.graphqland provide resolvers that read from the indexer’s DB. - If you serve REST, use the generated types to type DTOs and service responses.
Notes
- We export the schema needed by backend consumers (no raw event entities). It matches the data model our handlers populate.
- When the schema changes in a breaking way (e.g., a field becomes non‑null), bump the schema package version and update your backend accordingly.
