feat(api): GraphQL surface at /graphql via mercurius#48
Merged
Conversation
Tier 3 deferred item lands. Schema mirrors the REST shape with proper typed bindings — dApp devs that prefer GraphQL (subgraph muscle memory, join-heavy queries that would otherwise be 3+ REST round-trips) hit /graphql instead of stitching routes client-side. Resolvers delegate to the same Drizzle queries the REST routes use, so behaviour stays in lock-step across both surfaces. Custom BigInt scalar — block heights, fees, u256 values overflow JavaScript Number. Serialiser emits a string; parser accepts string or numeric literals. Same convention every modern EVM client follows (Etherscan, Alchemy, Infura). Initial query coverage: - block(height): Block (with .transactions sub-resolver) - blocks(limit, before): cursor-paginated [Block] - tx(hash): Tx (with .logs sub-resolver) - address(address): Address (with .txs and .transfers sub-resolvers) Address.txs uses the (from_addr|to_addr, block_height) composite indexes from migration 0004 — filter + sort served in one index scan. GraphiQL playground enabled in non-production for self-serve schema exploration. Production deploys flip it off via NODE_ENV. No subscriptions yet — push surface lives in chain node's gRPC StreamEvents; adding GraphQL subscriptions here would duplicate state and risk drift. Revisit when sdk-ts demand surfaces.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tier 3 deferred item from the indexer audit — GraphQL surface lands. Schema mirrors the REST shape with proper typed bindings. dApp devs that prefer GraphQL (subgraph muscle memory, join-heavy queries that would otherwise be 3+ REST round-trips) hit `/graphql` instead of stitching routes client-side.
Resolvers delegate to the same Drizzle queries the REST routes use, so behaviour stays in lock-step across both surfaces — adding a column to the schema only needs SDL update + one resolver line, not divergent maintenance.
What lands
`apps/api/src/graphql.ts` — Mercurius plugin registered at `/graphql`.
Initial query coverage:
`Address.txs` uses the `(from_addr|to_addr, block_height)` composite indexes from migration 0004 — filter + sort served in one index scan.
Custom BigInt scalar
Block heights, fees, u256 values overflow JavaScript Number. Serialiser emits a string; parser accepts string or numeric literals. Same convention every modern EVM client follows (Etherscan API, Alchemy, Infura).
GraphiQL playground
Enabled when `NODE_ENV !== 'production'`. Production deploys flip it off via env.
Out of scope
Test plan