mirror of
https://github.com/modrinth/code.git
synced 2026-08-25 00:55:25 +00:00
1.7 KiB
1.7 KiB
name, description
| name | description |
|---|---|
| tanstack-query | Convert Vue server-state code to TanStack Query. Use for useQuery, useMutation, cache invalidation, optimistic updates, or replacement of useAsyncData and manual ref patterns. |
Convert Data Code to TanStack Query
Read the applicable AGENTS.md files before you edit code.
Read the TanStack Query standard in full.
- Identify the target file from the request.
- Find
useAsyncData,useFetch, manual API refs, and fetch calls inonMounted. - Identify mutations that use manual loading, error, or result refs.
For queries:
- Replace manual fetch logic with
useQuery. - Get
api-clientwithinjectModrinthClient(). - Use a hierarchical query key with the resource, qualifier, and parameters.
- Use a computed query key for reactive parameters.
- Use a computed
enabledoption when the query depends on other data. - Use a shared query-option factory when multiple components use the query.
For mutations:
- Replace manual mutation state with
useMutation. - Invalidate or update related query data after success.
- Use an optimistic update only when the UI needs an immediate response.
- Cancel the applicable query and save its prior data before an optimistic update.
- Restore the prior data after an error. Invalidate the query after settlement.
Remove manual loading and error refs that TanStack Query replaces. Remove obsolete onMounted fetch calls.
Keep Nuxt SSR behavior. Match route-shell prefetch options when ReadyTransition and useReadyState depend on the query.
Check query keys, invalidation prefixes, reactive values, and rollback data.
Run only the checks that the user or the applicable AGENTS.md permits.