-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFR] Introduce useGetManyReference hook #3697
Conversation
pagination: Pagination, | ||
sort: Sort, | ||
filter: object, | ||
source: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used: sent in the payload just like the old call to crudGetManyReference
in useReferenceManyFieldController
did. See here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I don't understand what it does. And the dataProvider doc doesn't mention it, so I doubt anyone uses it.
* }; | ||
*/ | ||
const useGetManyReference = ( | ||
resource: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be the first argument, because it's not actually used for the query - just for the storage in the Redux store.
Suggested signature: ('comments', 'post_id', post_id, { page: 1, perPage: 10 }, { field: 'published_at', order: 'DESC' }, 'posts')
And this last argument should probably be called something like "cache_key"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's only a part of the cache key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides, I thought it would be better to have the same arguments order as in the other dataProvider hooks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's confusing, as the actual resource that this hook fetches is the reference. If you think about this hook outside of the context of the ReferenceInputs, it's just a way to get a list of resources wit ha particular filter...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const useGetManyReference = (
reference: string,
target: string,
id: Identifier,
pagination: Pagination,
sort: Sort,
filter: object,
referencingResource: string,
options?: any
) => { ... }
?
No description provided.