Add OrderFill token lookup index#13
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
📝 WalkthroughWalkthroughThe ChangesOrderFill Schema Indexing
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint skipped: no ESLint configuration detected in root package.json. To enable, add Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@schema.graphql`:
- Around line 24-26: The composite `@index` declaration on type OrderFill uses
fields: ["tokenId", "timestamp", "id"]—verify this matches Envio HyperIndex's
required type-level composite index syntax for composite indexes and adjust the
fields/order or annotation format if needed; after updating schema.graphql, run
pnpm codegen to regenerate TypeScript types and other generated artifacts so
OrderFill and its index are kept in sync with the schema.
- Around line 24-26: The GraphQL type OrderFill was changed in schema.graphql
but generated TypeScript types are stale; run the code generator to update
derived types. Execute the project codegen command (pnpm codegen) to regenerate
the TypeScript definitions that reference OrderFill so consumers (generated
types/usages) stay in sync with schema.graphql.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| type OrderFill | ||
| @index(fields: ["tokenId", "timestamp", "id"]) | ||
| @storage(postgres: true, clickhouse: true) { |
There was a problem hiding this comment.
🧩 Analysis chain
🌐 Web query:
Envio HyperIndex @index directive syntax documentation
💡 Result:
In Envio HyperIndex, the @index directive is used in your GraphQL schema to tell HyperIndex to create database indices for fields (and optionally composite indices) to improve query performance. Syntax (individual field index): type Transaction { userAddress: String! @index } Syntax (composite / multi-field index): // You put @index on a type and specify fields=[...] // Example from the docs: type Transfer @index(fields: ["from", "to", "tokenId"]) { from: String! @index to: String! @index tokenId: BigInt!... } Key behavior notes from the docs: - HyperIndex supports “the simplest form of indexing” by marking individual fields with @index.[1] - For “frequently query using multiple fields together”, HyperIndex recommends “composite indices” via the type-level form @index(fields: [...]).[1] - HyperIndex also creates indices automatically for all ID fields and for fields marked with @derivedFrom.[1] - The most common cause of slow queries is missing indices; if you filter or sort by a field without @index, add it.[1] If you share the exact schema snippet you’re trying to optimize (or which query is slow), I can suggest the minimal set of @index / composite @index(fields:...) directives to match your query patterns.
Citations:
Ensure composite @index is valid + regenerate after schema change
schema.graphql:@index(fields: ["tokenId", "timestamp", "id"])ontype OrderFillmatches Envio HyperIndex’s documented type-level composite index syntax.- Run
pnpm codegenafter thisschema.graphqlchange so generated types stay in sync.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@schema.graphql` around lines 24 - 26, The composite `@index` declaration on
type OrderFill uses fields: ["tokenId", "timestamp", "id"]—verify this matches
Envio HyperIndex's required type-level composite index syntax for composite
indexes and adjust the fields/order or annotation format if needed; after
updating schema.graphql, run pnpm codegen to regenerate TypeScript types and
other generated artifacts so OrderFill and its index are kept in sync with the
schema.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check if there are uncommitted codegen artifacts that suggest codegen was not run
# Check git status for generated files (common patterns for codegen output)
git status --short | rg -i 'generated|codegen|\.gen\.|types.*\.ts'Repository: enviodev/polymarket-v2-indexer
Length of output: 56
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# 1) Check full working tree status (not just filtered patterns)
echo "=== git status --short ==="
git status --short
# 2) Inspect schema.graphql around the referenced lines
echo
echo "=== schema.graphql (lines 1-80) ==="
nl -ba schema.graphql | sed -n '1,80p'Repository: enviodev/polymarket-v2-indexer
Length of output: 200
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "=== git status --short (porcelain) ==="
git status --short --porcelain=v1 || true
echo
echo "=== git status for schema.graphql ==="
git status --short --porcelain=v1 -- schema.graphql || true
echo
echo "=== schema.graphql lines 20-35 ==="
awk 'NR>=20 && NR<=35 { printf "%d:%s\n", NR, $0 }' schema.graphql
echo
echo "=== locate pnpm codegen script ==="
ls -la package.json pnpm-workspace.yaml pnpm-lock.yaml 2>/dev/null || true
rg -n '"codegen"' package.json pnpm-workspace.yaml 2>/dev/null || true
rg -n 'codegen' package.json pnpm-workspace.yaml 2>/dev/null || trueRepository: enviodev/polymarket-v2-indexer
Length of output: 985
Run pnpm codegen after this schema.graphql change (type OrderFill).
Generated types are derived from schema.graphql, so regenerating avoids stale code.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@schema.graphql` around lines 24 - 26, The GraphQL type OrderFill was changed
in schema.graphql but generated TypeScript types are stale; run the code
generator to update derived types. Execute the project codegen command (pnpm
codegen) to regenerate the TypeScript definitions that reference OrderFill so
consumers (generated types/usages) stay in sync with schema.graphql.
Summary
OrderFillindex ontokenId,timestamp, andid. Without it, queries like this can require a sequential scan and sort on largeOrderFilltables:This PR adds the V2 equivalent of the V1 token lookup index, adapted to the V2 schema.
Summary by CodeRabbit
Performance
Infrastructure