Skip to content
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

Issue using sortBy on <ReferenceField sortBy="..."> #167

Open
michaelcm opened this issue Dec 6, 2023 · 1 comment
Open

Issue using sortBy on <ReferenceField sortBy="..."> #167

michaelcm opened this issue Dec 6, 2023 · 1 comment

Comments

@michaelcm
Copy link

michaelcm commented Dec 6, 2023

Versions:

    "react-admin": "^4.16.2",
    "ra-data-hasura": "^0.6.0",

In this example I have two tables, one called users and one called people. This code snippet one field in UserList.tsx:

        <ReferenceField
          link="show"
          sortBy="people.display_name"
          source="people_id"
          reference="people"
        >
          <TextField source="display_name" />
        </ReferenceField>

The value of theoretically supported sortBy is documented here https://marmelab.com/react-admin/ReferenceField.html#sortby

Clicking on the column header to sort by people.display_name results in this error:

field 'people' not found in type: 'users_order_by'
image

Which makes me think the hasura data provider doesn't know how to handle sorting on related columns. Hoping for confirmation, or perhaps someone can point out what I'm doing wrong.

Thanks so much!
Michael

@michaelcm
Copy link
Author

So still an issue, working around this by creating a bunch of views for our tables, that have the necessary columns to sort and display the necessary values... a bit of overhead to work around something that seem to be incorrectly documented, or doesn't actually work.

CREATE OR REPLACE VIEW ... AS
SELECT
  ts.*,
  COUNT(DISTINCT g.id) AS group_count,
  COUNT(DISTINCT u.id) AS user_count,
FROM
...

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

No branches or pull requests

1 participant