Skip to content

(fix)ResourceGuesser: Fix <ResourceGuesser> ignores recordRepresentation prop #611

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

Merged
merged 3 commits into from
Mar 18, 2025

Conversation

slax57
Copy link
Contributor

@slax57 slax57 commented Mar 17, 2025

Problem

<ResourceGuesser> ignores the recordRepresentation prop.

E.g. the following Admin would not render the reviews using their author field (with RA components) without this fix:

export const UsingGuessers = () => (
  <HydraAdmin entrypoint={process.env.ENTRYPOINT}>
    <ResourceGuesser name="books" />
    <ResourceGuesser name="reviews" recordRepresentation="author" />
  </HydraAdmin>
);

Solution

Include the recordRepresentation prop when registering the definition context.

How to test

Run the unit tests.

In the storybook:

  1. Update the UsingGuessers story component to add recordRepresentation="author" to reviews
  2. Update BookList to use a <ReferenceArrayField reference="reviews" source="reviews" /> instead of a <FieldGuesser source="reviews" />
  3. Go to the book list and confirm reviews are represented using the author's name

@djhi djhi merged commit abc22f6 into main Mar 18, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants