Skip to content

fix(api): declare nested list pagination at the default it actually serves - #132

Merged
v1rtl merged 5 commits into
stagingfrom
fix/subdomains-pagination
Sep 29, 2026
Merged

v1rtl merged 5 commits into
stagingfrom
fix/subdomains-pagination

Conversation

@v1rtl

@v1rtl v1rtl commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

Domain.subdomains and Account.domains honoured first/skip at runtime but declared no arguments, so introspection and codegen couldn't see them. A parent with more than 10 children silently lost the rest: tide.eth on Sepolia reported subdomainCount: 11 while subdomains returned 10. Account.registrations had the opposite problem: it declared first: Int = 100 but served 10.

Changes

Declare what is served (d30f3b2)

  • subdomains(first: Int = 10, skip: Int = 0), Account.domains(first: Int = 10, skip: Int = 0), and Account.registrations corrected from = 100 to = 10.
  • The default stays at 10. The complexity budget charges a nested list 1 regardless of its row count (complexity.zig:283), so this constant is the only bound on nested fan-out. Raising it to 100 would allow ~10× more rows with no change in cost. Every other nested list (subdomainConnection, eventsConnection) already uses 10.
  • Handlers, prefetchers and the nested connections now share NESTED_DEFAULT_FIRST instead of literals.
  • docs/TESTING.md shows the new signature.

Variables in nested arguments (df45125)

  • Only root-field arguments were resolved against request variables. Nested handlers read arguments with getIntArg, which treats an unresolved $var as absent, so subdomains(first: $n) silently used the default. This affected every nested argument, not just this one.
  • expandSelections now resolves arguments at every depth.
  • An undefined variable is reported as VALIDATION_ERROR; it used to be a generic execution failure.

Introspection defaults (80809d9)

  • The generator parsed SDL defaults and threw them away, so codegen saw a bare optional first: Int.
  • defaultValue is now emitted for arguments and input fields.

Batching across page shapes (c578854)

  • The subdomain and account-domain loaders kept one (skip, first) per request and cleared it when a different shape arrived. The prefetch also only primed the first selection with a matching name.
  • As a result, these queries fell back to one point query per row:
    • differing args per nesting level: subdomains(first:1){ subdomains(first:2) }
    • aliased siblings: a: subdomains(first:1) b: subdomains(first:1, skip:1)
  • Both maps are now keyed by (key, skip, first), and every matching selection is primed.

Tests (f69d41b)

  • The old ops used alice.eth, which has a single child, so first: 1 produced identical output whether first was honoured, ignored, or the default changed.
  • A new fixture has 12 children, 3 grandchildren and 12 registrations. It pins:
    • the default page of 10
    • first/skip
    • variables and an undefined variable
    • aliased siblings and per-level arguments
    • Account.domains and Account.registrations
    • the introspected defaults
  • No existing golden changed.

Known, not fixed here

  • No completeness signal. The list still truncates without one; subdomainCount is the signal, and the description says so.
  • skip pages can differ between backends. SQLite orders name by bytes, while Postgres uses the database collation (hyphens sort differently). Fixing this needs COLLATE "C" on the (parent_name, name, protocol) index, which is a schema and performance decision.

zig build test-all: 89/89 steps, 1481/1481 tests (zig 0.16.0).

…erves

Domain.subdomains and Account.domains honoured first/skip at runtime but
declared no arguments, so introspection and codegen could not see them
and a parent with more than 10 children silently lost the rest.
Account.registrations declared first = 100 while serving 10.

Declare first: Int = 10, skip: Int = 0 on all three, matching what the
handlers have always returned. The default stays at 10 on purpose: the
complexity budget charges a nested list 1 regardless of its row count,
so this constant is the only bound on nested fan-out. Handlers and the
nested connections now share NESTED_DEFAULT_FIRST instead of literals.
Only root-field arguments were resolved against the request variables.
Nested handlers read their arguments with getIntArg and friends, which
treat an unresolved $var as absent, so subdomains(first: $n) silently
fell back to the default. expandSelections now resolves arguments at
every depth, and an undefined variable is reported as a validation
error instead of a generic execution failure.
The generator parsed and discarded SDL defaults, so every argument came
out of introspection as a bare optional with no defaultValue and codegen
clients could not see what an omitted first/skip means.
The subdomain and account-domain page loaders held a single (skip, first)
per request and cleared the map when another shape arrived, and the
prefetch only primed the first selection with a matching name. Differing
args across nesting levels, or aliased siblings such as
a: subdomains(first: 1) b: subdomains(first: 1, skip: 1), fell back to
one point query per row. Key both maps by (key, skip, first) and prime
every matching selection.
…hildren than a page

The single-child fixture could not distinguish an honoured first from an
ignored one or from a changed default. A dedicated fixture with 12
children, 3 grandchildren and 12 registrations pins the default page,
first/skip, variables, aliased siblings, per-level args and the
introspected defaults.
@v1rtl
v1rtl force-pushed the fix/subdomains-pagination branch from ee583e3 to f69d41b Compare September 29, 2026 13:56
@v1rtl v1rtl changed the title fix(api): declare pagination on Domain.subdomains so it stops silently truncating fix(api): declare nested list pagination at the default it actually serves Sep 29, 2026
@v1rtl
v1rtl merged commit e2888ae into staging Sep 29, 2026
4 checks passed
@v1rtl
v1rtl deleted the fix/subdomains-pagination branch September 29, 2026 14:59
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