@beignet/react-query 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @beignet/react-query
2
2
 
3
+ ## 0.0.23
4
+
5
+ ### Patch Changes
6
+
7
+ - afa7179: Teach generated UI to colocate React Query options and invalidation helpers under feature client modules.
8
+
3
9
  ## 0.0.22
4
10
 
5
11
  ## 0.0.21
package/README.md CHANGED
@@ -68,6 +68,54 @@ export function Providers({ children }: { children: ReactNode }) {
68
68
  }
69
69
  ```
70
70
 
71
+ ### 3. Add feature client helpers
72
+
73
+ Keep root `client/` for shared adapter setup, then put feature-specific query
74
+ options, mutation options, invalidation helpers, and hooks under
75
+ `features/<feature>/client/`:
76
+
77
+ ```ts
78
+ // features/todos/client/queries.ts
79
+ import type { QueryClient } from "@tanstack/react-query";
80
+ import { rq } from "@/client";
81
+ import { createTodo, listTodos } from "@/features/todos/contracts";
82
+
83
+ export function listTodosQueryOptions() {
84
+ return rq(listTodos).queryOptions({ query: {} });
85
+ }
86
+
87
+ export function createTodoMutationOptions() {
88
+ return rq(createTodo).mutationOptions();
89
+ }
90
+
91
+ export function invalidateTodos(queryClient: QueryClient) {
92
+ return rq(listTodos).invalidate(queryClient);
93
+ }
94
+ ```
95
+
96
+ Components can import those helpers and keep UI state separate from cache-key
97
+ construction:
98
+
99
+ ```tsx
100
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
101
+ import {
102
+ createTodoMutationOptions,
103
+ invalidateTodos,
104
+ listTodosQueryOptions,
105
+ } from "@/features/todos/client/queries";
106
+
107
+ function TodoList() {
108
+ const queryClient = useQueryClient();
109
+ const todosQuery = useQuery(listTodosQueryOptions());
110
+ const createTodoMutation = useMutation({
111
+ ...createTodoMutationOptions(),
112
+ onSuccess: () => invalidateTodos(queryClient),
113
+ });
114
+
115
+ return <div>{/* ... */}</div>;
116
+ }
117
+ ```
118
+
71
119
  ## Usage
72
120
 
73
121
  ### Options-first API (recommended)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beignet/react-query",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "type": "module",
5
5
  "description": "TanStack Query integration for Beignet",
6
6
  "main": "./dist/index.js",
@@ -53,14 +53,21 @@ Follow the existing style unless intentionally migrating. Do not mix both
53
53
  within one feature.
54
54
 
55
55
  ```ts
56
+ import type { QueryClient } from "@tanstack/react-query";
56
57
  import { rq } from "@/client";
57
58
  import { createTodo, listTodos } from "@/features/todos/contracts";
58
59
 
59
- export const listTodosQuery = () =>
60
- rq(listTodos).queryOptions({ query: { limit: 20 } });
60
+ export function listTodosQueryOptions() {
61
+ return rq(listTodos).queryOptions({ query: { limit: 20 } });
62
+ }
63
+
64
+ export function createTodoMutationOptions() {
65
+ return rq(createTodo).mutationOptions();
66
+ }
61
67
 
62
- export const createTodoMutation = () =>
63
- rq(createTodo).mutationOptions();
68
+ export function invalidateTodos(queryClient: QueryClient) {
69
+ return rq(listTodos).invalidate(queryClient);
70
+ }
64
71
  ```
65
72
 
66
73
  ## Components