hasura / ra-data-hasura

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

add sort ability to support nulls_first and nulls_last #139

Closed n3n closed 1 year ago

n3n commented 1 year ago

I use @ as a operation separator from field name (the same as filter but for sort)

Example

List default sort field

const TodoList = (props) => (
  <List sort={{ field: 'title@nulls_last,is_completed', order: 'asc,desc' }} {...props}>
    <Datagrid rowClick="edit">...</Datagrid>
  </List>
);

will generate a query with an order_by:

order_by: [{ title: "asc_nulls_last" }, { is_completed: "desc" }]

Field sortBy

const TodoList = (props) => (
  <List {...props}>
    <Datagrid>
        <TextField source="title" sortBy="title@nulls_last" />
    </Datagrid>
  </List>
);

will generate a query with an order_by:

order_by: [{ title: "asc_nulls_last" }]
arjunyel commented 1 year ago

@n3n thank you for both of your PRs friend!