Skip to content

fix: always output valid types#152

Merged
atilafassina merged 3 commits intomainfrom
typegen/failed-query
Mar 4, 2026
Merged

fix: always output valid types#152
atilafassina merged 3 commits intomainfrom
typegen/failed-query

Conversation

@atilafassina
Copy link
Contributor

@atilafassina atilafassina commented Mar 3, 2026

  • fixes Array< ; > bug
  • ignores appKitTypes.d.ts from ESLint config
  • cache queries individually
  • extends QueryRegistry cache to add retry: boolean
  • logs a warning when cache file is corrupted

New Behavior:

When a describe query fails, query result will be typed as unknown and cache will have retry: true flag. Also, query builder will log which carries are a cache HIT when which weren't. And in case a certain describe fails, it will log the error from the server.


closes #125

@atilafassina atilafassina marked this pull request as ready for review March 3, 2026 15:40
Copilot AI review requested due to automatic review settings March 3, 2026 15:40
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the AppKit type-generator to always emit a valid query schema/type (even when DESCRIBE QUERY fails or returns no columns) and introduces a cache retry flag to re-attempt schema generation later.

Changes:

  • Update convertToQueryType to return { type, hasResults } and emit result: unknown when no columns are present.
  • Ensure generateQueriesFromDescribe includes failed queries in output and cache (marked retry: true), and persists cache incrementally to survive partial failures.
  • Bump cache version to 2 and update tests to cover new behaviors (unknown result types, partial failures, cache writes, hasResults).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/appkit/src/type-generator/query-registry.ts Core logic changes: unknown result fallback, retry-aware cache usage, incremental caching, new return shape for convertToQueryType.
packages/appkit/src/type-generator/cache.ts Cache schema bumped to v2 with retry field; adds warning log on load failures.
packages/appkit/src/type-generator/tests/query-registry.test.ts Updates tests for new convertToQueryType return value and adds hasResults coverage.
packages/appkit/src/type-generator/tests/generate-queries.test.ts Expands tests to ensure failed queries still produce schemas, unknown result types, and cache writes occur per query.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@atilafassina atilafassina self-assigned this Mar 3, 2026
@atilafassina atilafassina added the bug Something isn't working label Mar 3, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@pkosiec pkosiec requested review from a team and removed request for a team March 4, 2026 09:52
@atilafassina atilafassina merged commit b350a46 into main Mar 4, 2026
6 checks passed
@atilafassina atilafassina deleted the typegen/failed-query branch March 4, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: generate-types emits invalid TS for queries with empty DESCRIBE QUERY schema (result: Array<{ ; }>)

3 participants