You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When creating a resource, I want to be able a related resource of the same type. A good example is a catalogue API. When I create a folder, I want its children's list to update.
type Folder = {
id: number
parentId: number
name: string
children?: Folder[] // the api only returns up to one level children depth
childrenCount: number
}
createFolder({}, { id: uuid(), name: fileName, parentId: props.id }, [
[FolderResource.detailShape(), { id: props.id }, (updateParamA, updateParamB) => {
// See below
console.log(updateParamA, updateParamB)
}]
])
My expectation is that updateParamA would return the folder with props.id, allowing me to update it by adding the id of my new folder to the FolderResource. It doesn't even have to be optimistic, I just want to be able to update my entity.
I feel unable to visualize right now how to do it with the existing tools in rest-hooks, probable due to my inexperience with the library.
Also, the type above yields to the following schema:
static schema: any = { // have to use any here as schema refers to self
children: [FolderResource.asSchema()],
};
Using the detailShape returns ids for these ie: children: ['1', '2']. Is there any way we can get the fully formed/nested objects, ie: children[FOLDER_1, FOLDER2]?
This is because returning ids prevents doing something like classList.children.map directly without creating a new component as we have to use useCache for each element row. Alternatively a useCache with multiple ids would be great (can a special shape be created for this?)
The text was updated successfully, but these errors were encountered:
Thanks for the report. We can probably get something in for the next useFetcher() design.
To understand this use case, can you get back to me if what I say is correct? You have a bunch of Folders with no parent, then you make a new folder with a bunch of children Ids - so those children need the new parent. Instead of having to fetch all those children to get the updated parent you'd like their data to be updated to point to the new ID from the created parent.
When creating a resource, I want to be able a related resource of the same type. A good example is a catalogue API. When I create a folder, I want its children's list to update.
My expectation is that
updateParamA
would return the folder withprops.id
, allowing me to update it by adding the id of my new folder to the FolderResource. It doesn't even have to be optimistic, I just want to be able to update my entity.I feel unable to visualize right now how to do it with the existing tools in rest-hooks, probable due to my inexperience with the library.
Also, the type above yields to the following schema:
Using the
detailShape
returns ids for these ie:children: ['1', '2']
. Is there any way we can get the fully formed/nested objects, ie:children[FOLDER_1, FOLDER2]
?This is because returning ids prevents doing something like
classList.children.map
directly without creating a new component as we have to useuseCache
for each element row. Alternatively auseCache
with multipleids
would be great (can a special shape be created for this?)The text was updated successfully, but these errors were encountered: