Highlights
Deprecated networking definitions were removed from rest-hooks
exports, and moved to @rest-hooks/legacy.
FlatEntity, SimpleRecord, NestedEntity, schemas, isEntity, Entity, Resource, SimpleResource, SchemaDetail, SchemaList, Method
These are still supported! They are simply moved to @rest-hooks/legacy. This allows smooth incremental migrations.
yarn add @rest-hooks/legacy@2.2.0
- has all of these, and is compatible with both
rest-hooks
5 and 6.
- Upgrade
rest-hooks
&@rest-hooks/legacy
to 6. - Gradually migrate to @rest-hooks/rest
@rest-hooks/endpoint changes
SimpleRecord -> [Object](https://resthooks.io/docs/api/Object)
@rest-hooks/rest changes from 2 -> 3
These add on to the existing changes of @rest-hooks/rest from @rest-hooks/legacy
If
Resource.fromJS()
was used to customize normalization process, useprocess()
instead.class MyResource extends Resource {
static process(input: any, parent: any, key: string | undefined): any {
return {
...input,
extraThing: 5,
};
}
}
New default error behavior
- To keep existing:
class MyResource extends Resource {
static getEndpointExtra(): EndpointExtraOptions | undefined {
return {
errorPolicy: error => 'soft' as const,
};
}
}
- To keep existing:
Full list of changes
@rest-hooks/endpoint
Entity
- fromJS() -> process() to customize init
- normalize results in POJO rather than instances
- This is only meaningful for those inspecting the rest hooks state directly
- FlatEntity, SimpleRecord removed (use @rest-hooks/legacy)
@rest-hooks/rest
- peerDep @rest-hooks/endpoint > 2
@rest-hooks/core
buildInferredResult -> inferResults
Error behavior
useError() will no longer create synthetic errors for missing entities
useError() errorPolicy
polled fetch errors are always 'soft'
@rest-hooks/rest
- 5xx: 'soft'
- 4xx, 3xx, etc: 'hard'
peerDep @rest-hooks/endpoint > 2
rest-hooks
Removed exports from 'rest-hooks': NestedEntity, schemas, isEntity, Entity, Resource, SimpleResource, SchemaDetail, SchemaList, Method
- use @rest-hooks/legacy, or @rest-hooks/rest instead
@rest-hooks/legacy
- peerDep @rest-hooks/endpoint > 2