@beignet/react-query 0.0.31 → 0.0.33

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,18 @@
1
1
  # @beignet/react-query
2
2
 
3
+ ## 0.0.33
4
+
5
+ ### Patch Changes
6
+
7
+ - c514ffc: Document the Next.js cached request-context convention separately from React
8
+ Query prefetching, and update generated agent guidance to use
9
+ `lib/server-context.ts` for shared Server Component request state.
10
+ - ae6d7f9: Document the Next.js server prefetch convention and teach generated agent
11
+ guidance to preserve contract query keys while replacing server query
12
+ functions with direct use-case calls.
13
+
14
+ ## 0.0.32
15
+
3
16
  ## 0.0.31
4
17
 
5
18
  ## 0.0.30
package/README.md CHANGED
@@ -200,6 +200,33 @@ export async function TodoPage({ params }: { params: { id: string } }) {
200
200
  }
201
201
  ```
202
202
 
203
+ That prefetch path uses the generated HTTP query function. In Next.js apps,
204
+ ordinary `{ contract, useCase }` routes can avoid an internal HTTP request by
205
+ using a cached server-context helper plus a server-only prefetch helper that
206
+ preserves the contract query key and replaces only the server `queryFn`:
207
+
208
+ ```tsx
209
+ import { getTodoUseCase } from "@/features/todos/use-cases";
210
+ import { getAppRequestContext } from "@/lib/server-context";
211
+ import { serverUseCaseQueryOptions } from "@/lib/server-react-query";
212
+
213
+ const ctx = await getAppRequestContext();
214
+ const queryClient = makeQueryClient();
215
+
216
+ await queryClient.prefetchQuery(
217
+ serverUseCaseQueryOptions(
218
+ rq(getTodo).queryOptions({ path: { id: params.id } }),
219
+ getTodoUseCase,
220
+ ctx,
221
+ { id: params.id },
222
+ ),
223
+ );
224
+ ```
225
+
226
+ Use the use-case path only when the use case output is the contract success
227
+ body. Use the HTTP `rq(...)` path when the route handler owns response mapping,
228
+ headers, streaming, or other HTTP-layer behavior.
229
+
203
230
  #### Mutation options
204
231
 
205
232
  ```tsx
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@beignet/react-query",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "type": "module",
5
5
  "description": "TanStack Query integration for Beignet",
6
6
  "main": "./dist/index.js",
@@ -97,6 +97,18 @@ Call server behavior through Beignet contracts and typed clients.
97
97
 
98
98
  - Use `queryOptions(...)` so options work with `useQuery`, `prefetchQuery`,
99
99
  `fetchQuery`, and server prefetching.
100
+ - In Next.js Server Components, get Beignet request state from the app's
101
+ cached server-only context helper (usually `lib/server-context.ts`). Layouts
102
+ may read `ctx.auth`, `ctx.tenant`, and request metadata from that context;
103
+ feature data still belongs behind use cases.
104
+ - For React Query hydration, use the app's server-only prefetch helper (usually
105
+ `lib/server-react-query.ts`) on top of that context for direct
106
+ `{ contract, useCase }` routes: keep the `rq(contract).queryOptions(...)` key
107
+ and replace only the server `queryFn` with the use case call. Do not invent a
108
+ parallel `rqServer` helper.
109
+ - Use HTTP prefetch through `rq(contract).queryOptions(...)` when the route
110
+ handler owns response mapping, headers, streaming, or other HTTP-layer
111
+ behavior.
100
112
  - Use `mutationOptions(...)` with `useMutation`.
101
113
  - Use `infiniteQueryOptions(...)` with `useInfiniteQuery` for paginated
102
114
  contracts. Prefer static `path`/`query` plus `page(...)`; if every page needs