@emeryld/rrroutes-client 2.8.0 → 2.8.2
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/README.md +25 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/routesV3.client.batch.d.ts +2 -2
- package/dist/routesV3.client.d.ts +3 -3
- package/dist/routesV3.client.get.d.ts +2 -2
- package/dist/routesV3.client.infiniteGet.d.ts +2 -2
- package/dist/routesV3.client.mutation.d.ts +2 -2
- package/dist/routesV3.client.types.d.ts +48 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,6 +85,31 @@ const client = createRouteClient({
|
|
|
85
85
|
})
|
|
86
86
|
```
|
|
87
87
|
|
|
88
|
+
If you want a typed client-wide hook error without passing generics everywhere, augment the global RRRoutes client register once:
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
import { createRouteClient, type HttpError } from '@emeryld/rrroutes-client'
|
|
92
|
+
|
|
93
|
+
declare global {
|
|
94
|
+
namespace RRRoutesClient {
|
|
95
|
+
interface Register {
|
|
96
|
+
error: HttpError
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const client = createRouteClient({
|
|
102
|
+
baseUrl: 'https://api.example.com',
|
|
103
|
+
queryClient,
|
|
104
|
+
})
|
|
105
|
+
|
|
106
|
+
const users = client.build(registry.byKey['GET /v1/users'])
|
|
107
|
+
const result = users.useEndpoint()
|
|
108
|
+
// result.error is now typed as HttpError | null
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
You can still override per-client by passing `createRouteClient<Names, TError>(...)` when needed.
|
|
112
|
+
|
|
88
113
|
### 2) Build endpoints from your registry
|
|
89
114
|
|
|
90
115
|
```ts
|