@aws/nx-plugin-mcp 1.8.0 → 1.9.0

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.
@@ -381,6 +381,29 @@ function UserList() {
381
381
  }
382
382
  ```
383
383
 
384
+ ### Prefetching in Route Loaders
385
+
386
+ If your website uses TanStack Router, the generator also adds the query client and the tRPC options proxy to the router context. The context property is named after the API in camel case, so a `MyApi` API is available as `context.myApi` and several APIs can be connected to the same website. Use them to prefetch data in a route `loader`, before the route renders:
387
+
388
+ ```tsx {5-7}
389
+ import { createFileRoute } from '@tanstack/react-router';
390
+
391
+ export const Route = createFileRoute('/users')({
392
+ loader: async ({ context }) => {
393
+ // The context properties are optional, so use a non-null assertion or a guard
394
+ const { queryClient, myApi } = context;
395
+ await queryClient!.ensureQueryData(myApi!.users.list.queryOptions());
396
+ },
397
+ component: UserList,
398
+ });
399
+ ```
400
+
401
+ The component can then read the prefetched data with `useQuery(trpc.users.list.queryOptions())`, which resolves immediately from the cache.
402
+
403
+ :::note
404
+ An API named `Auth`, `QueryClient` or `RuntimeConfig` would clash with the `auth`, `queryClient` and `runtimeConfig` context properties, so it is not added to the router context and the generator logs a warning. Use a different API name if you need it in the router context.
405
+ :::
406
+
384
407
  ### Infinite Queries
385
408
 
386
409
  Handle pagination with infinite queries:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin-mcp",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",