Steams / ra-data-hasura-graphql

React-admin data provider for Hasura GraphQL endpoints
MIT License
211 stars 33 forks source link

Make it possible to reference a nested object in a reference many field #77

Closed remiremi closed 3 years ago

remiremi commented 3 years ago

For example if you have countries associated to book authors, and you want to show all books for a given country you could now do

const CountryShow = (props: any) => {
  return (
    <Show {...props}>
      <SimpleShowLayout>
        <TextField source="name" />
        <ReferenceManyField
          perPage={5}
          label="Book"
          reference="book"
          target="author.country_id"
          sort={{ field: "written", order: "DESC" }}
        >
          <Datagrid rowClick="show">
            <TextField source="name" />
            <DateField source="written" />
            <DateField source="published" />
          </Datagrid>
        </ReferenceManyField>
      </SimpleShowLayout>
    </Show>
  );
};
cpursley commented 3 years ago

@remiremi this repository is now depreciated. The Hasura organization has adopted and now maintains this library. Going forward, you can use this: https://github.com/hasura/ra-data-hasura