@beignet/react-query 0.0.32 → 0.0.34
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 +13 -0
- package/README.md +27 -0
- package/package.json +1 -1
- package/skills/client/SKILL.md +12 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @beignet/react-query
|
|
2
2
|
|
|
3
|
+
## 0.0.34
|
|
4
|
+
|
|
5
|
+
## 0.0.33
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- c514ffc: Document the Next.js cached request-context convention separately from React
|
|
10
|
+
Query prefetching, and update generated agent guidance to use
|
|
11
|
+
`lib/server-context.ts` for shared Server Component request state.
|
|
12
|
+
- ae6d7f9: Document the Next.js server prefetch convention and teach generated agent
|
|
13
|
+
guidance to preserve contract query keys while replacing server query
|
|
14
|
+
functions with direct use-case calls.
|
|
15
|
+
|
|
3
16
|
## 0.0.32
|
|
4
17
|
|
|
5
18
|
## 0.0.31
|
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
package/skills/client/SKILL.md
CHANGED
|
@@ -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
|