Skip to content

Make mock indexer entity queries generic - #1509

Merged
DZakh merged 1 commit into
mainfrom
codex/mock-indexer-generic-entity-api
Jul 29, 2026
Merged

Make mock indexer entity queries generic#1509
DZakh merged 1 commit into
mainfrom
codex/mock-indexer-generic-entity-api

Conversation

@DZakh

@DZakh DZakh commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary

  • accept schema entity names as plain strings in the mock indexer API
  • return polymorphic entity records directly from query, queryHistory, and queryRaw
  • update scenario tests to pass their schema entity names directly and provide result annotations only where ReScript inference needs them

Why

The mock indexer was coupled to generated Indexer.Entities.name values. That coupling blocks moving it into the internal test-indexer solution in the envio test package, where scenario-generated entity-name types are unavailable. Returning the caller-selected entity type directly keeps the API lightweight without introducing a separate opaque entity wrapper.

Impact

Mock-indexer queries are intentionally less type-safe at the entity-name boundary: a string and its expected result type can disagree. Runtime entity lookup still validates the supplied name against the loaded project config.

Validation

  • pnpm exec rescript
  • pnpm exec tsc --noEmit
  • 153 focused Vitest tests across the affected mock-indexer, storage, rollback, and schema suites
  • git diff --check

Summary by CodeRabbit

  • Tests
    • Updated test coverage for querying entities by name.
    • Improved type validation for entity and history query results.
    • Updated loading, storage, rollback, schema, and SQL-generation tests to use consistent entity configuration.
    • Removed an incorrect duplicate deletion test and retained the correct string-ID coverage.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1b59fc9b-95df-49ae-8269-2bfd436414c2

📥 Commits

Reviewing files that changed from the base of the PR and between 6284551 and fe45bcf.

📒 Files selected for processing (11)
  • scenarios/test_codegen/test/ConcurrentWrite_test.res
  • scenarios/test_codegen/test/E2E_test.res
  • scenarios/test_codegen/test/LoadLayer_test.res
  • scenarios/test_codegen/test/WriteRead_test.res
  • scenarios/test_codegen/test/helpers/MockIndexer.res
  • scenarios/test_codegen/test/lib_tests/ClickHouse_test.res
  • scenarios/test_codegen/test/lib_tests/EntityIdType_test.res
  • scenarios/test_codegen/test/lib_tests/PgStorage_test.res
  • scenarios/test_codegen/test/rollback/Rollback_test.res
  • scenarios/test_codegen/test/schema_types/BigDecimal_test.res
  • scenarios/test_codegen/test/schema_types/Timestamp_test.res

📝 Walkthrough

Walkthrough

The test MockIndexer now resolves entities by string names, with updated query and history-query types. Code generation tests were migrated to string-based entity lookup and explicit Promise result annotations across loading, storage, write/read, rollback, and schema scenarios.

Changes

Entity Lookup API Migration

Layer / File(s) Summary
MockIndexer lookup contract and implementation
scenarios/test_codegen/test/helpers/MockIndexer.res
entityConfig, query, and queryHistory now use string entity names, resolve configurations by name, and apply the updated history change type.
Typed query and history call sites
scenarios/test_codegen/test/{ConcurrentWrite_test.res,E2E_test.res,WriteRead_test.res}, scenarios/test_codegen/test/rollback/*, scenarios/test_codegen/test/schema_types/*
Query and history assertions use quoted entity names and explicit Promise result types.
Entity configuration call sites
scenarios/test_codegen/test/LoadLayer_test.res, scenarios/test_codegen/test/lib_tests/*
Entity configuration setup uses quoted names across load-layer, ClickHouse, PostgreSQL, and entity ID tests; a duplicated entity ID test is removed.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

  • enviodev/hyperindex#1482: Updates related MockIndexer entity identification and typed query call sites in the same test area.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: making mock indexer entity queries generic.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@DZakh
DZakh marked this pull request as ready for review July 29, 2026 09:35
@DZakh
DZakh merged commit 9058a93 into main Jul 29, 2026
8 checks passed
@DZakh
DZakh deleted the codex/mock-indexer-generic-entity-api branch July 29, 2026 10:39
DZakh pushed a commit that referenced this pull request Jul 29, 2026
…tart-at-head-recovery

The base picked up main, bringing configurable chain-id storage (#1507) and
generic mock indexer entity queries (#1509).

One conflict, in makeSetReadyAtQuery: #1507 turned it into a one-row-at-a-time
update because the id column is INTEGER or BIGINT depending on ChainId.mode, so
`= ANY($2::int[])` no longer holds for every configuration. Took that shape and
kept the `IS NULL` guard on top; the caller loops the chain ids, so the guard
applies per row exactly as it did to the array form.

Source.make's `~chain` became `~chainId` in #1509; renamed at the call sites in
the resume tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DL4RDYUpZcK2YyydfSvqLc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant