hasura / ra-data-hasura

react-admin data provider for Hasura GraphQL Engine
MIT License
336 stars 70 forks source link

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

Open michaelcm opened 9 months ago

michaelcm commented 9 months ago

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 commented 7 months ago

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
...