Skip to content

feat(clients): OpenAPI-generated React Query hooks#152

Merged
Miracle656 merged 1 commit into
Miracle656:mainfrom
Asheeyah23:feat/react-query-client
Jun 29, 2026
Merged

feat(clients): OpenAPI-generated React Query hooks#152
Miracle656 merged 1 commit into
Miracle656:mainfrom
Asheeyah23:feat/react-query-client

Conversation

@Asheeyah23

Copy link
Copy Markdown
Contributor

Closes #146

What

Adds clients/react-query/ — a typed @tanstack/react-query client for the Wraith API. Following the issue's suggestion (orval or openapi-fetch + React Query), this uses openapi-typescript to generate the request/response types from openapi.json and openapi-fetch for transport, so every hook is fully typed end-to-end with no hand-maintained models. It mirrors the layout of the existing clients/python/.

Acceptance criteria

  • Hooks for every list endpoint — one module per resource under src/hooks/:
    Hook Endpoint
    useIncomingTransfers GET /transfers/incoming/{address}
    useOutgoingTransfers GET /transfers/outgoing/{address}
    useAddressTransfers GET /transfers/address/{address}
    useTransactionTransfers GET /transfers/tx/{txHash}
    useAccountSummary GET /accounts/{address}/summary
    useAccountTransfers GET /accounts/{address}/transfers
    usePopularAssets GET /assets/popular
    useNftTransfers GET /nfts/transfers
    useWebhooks GET /webhooks
    useWebhookDeliveries GET /webhooks/{id}/deliveries
    useHostFunctionLogs GET /host-fn/{contractId}
    useStatus GET /status
  • Regenerable from CInpm run generate runs openapi-typescript ../../openapi.json -o src/schema.d.ts. The new .github/workflows/react-query-sdk.yml regenerates the schema and fails on drift (git diff --exit-code), then typechecks, tests, and builds — so the client can never silently fall out of sync with the spec.

API

createWraithClient({ baseUrl }) + <WraithClientProvider client={…}> wire a typed client through context; hooks read it via useWraithClient(). Non-2xx responses reject with a typed WraithError (.status, .body). A queryKeys factory is exported for invalidation/prefetch.

Verification

  • npm run generate is idempotent (no drift). tsc --noEmit clean; npm run build emits dist/.
  • vitest run4 passed: request shaping (path + query serialization), response parsing, collection endpoint without params, and non-2xx → WraithError mapping.

Note: the spec's transfer schema doesn't model an isSac field, so the typed hooks expose the fields the spec declares (amount, displayAmount, …); the generated types follow openapi.json exactly.

Add clients/react-query/ — a typed @tanstack/react-query client for the
Wraith API. Request/response types are generated from openapi.json with
openapi-typescript and the transport is openapi-fetch, so the hooks are
fully typed end to end with no hand-maintained models.

- Hooks for every list endpoint: useIncomingTransfers, useOutgoingTransfers,
  useAddressTransfers, useTransactionTransfers, useAccountSummary,
  useAccountTransfers, usePopularAssets, useNftTransfers, useWebhooks,
  useWebhookDeliveries, useHostFunctionLogs, useStatus.
- createWraithClient + WraithClientProvider/useWraithClient wire a typed
  client through context; non-2xx responses reject with a typed WraithError.
- Stable queryKeys factory for invalidation/prefetch.
- npm run generate regenerates src/schema.d.ts from ../../openapi.json; a
  React Query SDK workflow regenerates in CI and fails on drift, then
  typechecks, tests, and builds.
- vitest tests cover request shaping (path + query params), response
  parsing, and error mapping.

Closes Miracle656#146
@drips-wave

drips-wave Bot commented Jun 29, 2026

Copy link
Copy Markdown

@Asheeyah23 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Miracle656 Miracle656 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Clean, fully-isolated additive client (clients/react-query/, own package.json/lockfile/tsconfig — can't affect the main build). Types are generated from openapi.json via openapi-typescript + openapi-fetch (no hand-maintained models), with a drift-check workflow (git diff --exit-code after npm run generate) so it can't silently desync from the spec. Hooks for every list endpoint, typed WraithError on non-2xx, queryKeys factory for invalidation, 4 vitest passing. Mirrors clients/python/. Closes #146.

@Miracle656 Miracle656 merged commit f03ec80 into Miracle656:main Jun 29, 2026
1 check passed
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.

OpenAPI-generated React Query hooks

2 participants