Skip to content

add TanStack Query query + mutation output targets#205

Open
swalker326 wants to merge 3 commits intospecta-rs:mainfrom
swalker326:feat/tanstack-query-output-target
Open

add TanStack Query query + mutation output targets#205
swalker326 wants to merge 3 commits intospecta-rs:mainfrom
swalker326:feat/tanstack-query-output-target

Conversation

@swalker326
Copy link

@swalker326 swalker326 commented Mar 18, 2026

Summary

  • add a new CommandOutputTarget enum and Builder::command_output_target(...) config so command generation can target either invoke functions (default) or TanStack Query helpers
  • when CommandOutputTarget::TanstackQuery is selected, generate commands.* wrappers that return queryOptions({ queryKey, queryFn }) using @tanstack/react-query, with query keys including command name and argument object when present
  • add first-class mutation generation via Builder::mutation_commands([...]); commands in this set generate mutationOptions({ mutationKey, mutationFn }) while non-listed commands continue generating queryOptions
  • expose the new output target + mutation config in the public API and document them in crate docs/README
  • add a new end-to-end example app at examples/react-query-app that uses generated query and mutation helpers from React

How to test (new example app)

  • pnpm install
  • cargo run --manifest-path examples/react-query-app/src-tauri/Cargo.toml (generates examples/react-query-app/src/bindings.ts)
  • pnpm --dir examples/react-query-app tauri dev
  • in the app:
    • verify query helpers by changing the name and seeing greeting/list queries update
    • verify mutation helpers by adding/deleting todos and seeing list invalidation refresh results

Notes

  • inspired by issue Tanstack Query queryOptions API #147 and follows its proposed queryOptions shape as the starting point
  • full workspace cargo test --all --all-features still has unrelated example/plugin formatter API failures in this repo; validation used here:
    • cargo check -p tauri-specta --all-features --lib
    • cargo check -p tauri-specta-example-react-query-app
    • pnpm --dir examples/react-query-app exec tsc --noEmit
    • pnpm --dir examples/react-query-app build

@swalker326 swalker326 marked this pull request as draft March 18, 2026 20:51
@swalker326 swalker326 changed the title add TanStack Query command output target add TanStack Query query + mutation output targets Mar 18, 2026
@swalker326 swalker326 marked this pull request as ready for review March 18, 2026 21:43
@oscartbeaumont oscartbeaumont linked an issue Mar 20, 2026 that may be closed by this pull request
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.

Tanstack Query queryOptions API

1 participant