feat: add @tuyau/svelte-query adapter#111
Open
ebauger wants to merge 2 commits intoJulien-R44:mainfrom
Open
Conversation
Align all packages to the same @tanstack/query-core version to prevent skipToken Symbol mismatches caused by duplicate module instances in the pnpm workspace.
Add a Svelte 5 adapter for Tuyau's type-safe TanStack Query integration, following the same architecture as @tuyau/react-query and @tuyau/vue-query. Features: - createTuyauSvelteQueryClient() factory with Proxy-based API tree - Type-safe queryOptions, mutationOptions, infiniteQueryOptions builders - Svelte context helpers (setTuyauContext, useTuyau, useTuyauClient) - Full skipToken support for conditional queries - Query key/filter helpers for cache management Key design decisions: - queryOptions/mutationOptions/infiniteQueryOptions are inlined as identity functions because @tanstack/svelte-query's barrel export re-exports .svelte component files that Node.js cannot load without a compiler - Types imported via `import type` from @tanstack/svelte-query (safe, erased at build time) - Peer depends on @tanstack/svelte-query ^6.1.0 (Svelte Query v6 requires Svelte 5, uses same @tanstack/query-core v5 as react/vue adapters) - Integration tests use vitest with @sveltejs/vite-plugin-svelte following TanStack/query's own test patterns ($effect.root + withEffectRoot helper)
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.
Because I love Svelte and Tuyau, cadeau pour la communauté Adonis.js! Merci @Julien-R44
Summary
Adds a new
@tuyau/svelte-querypackage — a Svelte 5 adapter for Tuyau's type-safe TanStack Query integration, following the same architecture as@tuyau/react-queryand@tuyau/vue-query.createTuyauSvelteQueryClient()— Proxy-based factory mirroring the API route tree, identical pattern to the Vue/React adapters@tuyau/query-corefor shared logicsetTuyauContext(),useTuyau(),useTuyauClient()using Svelte'ssetContext/getContext@tanstack/svelte-query^6.1.0 (Svelte Query v6 requires Svelte 5, shares@tanstack/query-corev5 with the React/Vue adapters)Design decisions
Inlined identity functions instead of importing from
@tanstack/svelte-query:The barrel export of
@tanstack/svelte-queryre-exports.sveltecomponent files (HydrationBoundary,QueryClientProvider) and.svelte.jsrune files that Node.js cannot load without the Svelte compiler. SincequeryOptions/mutationOptions/infiniteQueryOptionsare pure identity functions (they just return their input for type inference), we construct the result objects directly. Types are still imported viaimport typefrom@tanstack/svelte-query(safe — erased at build time).Dual test runner setup:
Option-object-level tests run in Japa (37 tests, no Svelte compiler needed). Integration tests (
createQuery,createMutation,createInfiniteQueryend-to-end) run in vitest with@sveltejs/vite-plugin-svelte, using$effect.root()via awithEffectRoothelper — matching TanStack/query's own Svelte test patterns.@tanstack/query-corebump to ^5.96.2:Required because
@tanstack/svelte-query@6.1.13depends on@tanstack/query-core@5.96.2. Without aligning all workspace packages to the same version, pnpm resolves two separate copies, causingskipToken(a uniqueSymbol) to differ between modules and silently breaking conditional query detection.Test plan
pnpm --filter @tuyau/svelte-query build— tsup ESM + DTS (17 KB)pnpm --filter @tuyau/svelte-query typecheck— cleanpnpm --filter @tuyau/svelte-query lint— 0 warnings, 0 errorspnpm --filter @tuyau/svelte-query test— 37 Japa + 7 vitest = 44 tests passingpnpm --filter @tuyau/query-core test— 23/23 (no regression)pnpm --filter @tuyau/vue-query test— 47/47 (no regression)pnpm --filter @tuyau/react-query test— 80/80 (no regression)