ra-data-hasura-graphql
ra-data-hasura-graphql copied to clipboard
Hasura relationships (nested resources)
How can we query for relationships in Hasura?
I saw #30 but it would be better if we could have it out of the box. What is the benefit of this over ra-data-hasura if we can't fetch nested resources?
I saw that here https://github.com/Steams/ra-data-hasura-graphql/blob/7397a643293b9582e26795d73129fd84f032070d/src/buildGqlQuery.js#L46 OBJECT types are being dropped. Maybe we could keep them and add their fields.
Also, it would be great if we could fetch only requested fields, not whole introspection result.
Nested resources + fetch only requested fields = GraphQL win :)
Do you have a suggestion on how to implement this? What else would you need to do besides removing object exclusion check?
I think the key thing is getting only requested fields. If we don't have that, than we could be stuck in endless loops with nested queries.
For example, if we have author
that has relationship posts
and post
has author
, then, without specifically asking for only required fields, a query like author { posts }
would be stuck in a loop.
@ceracera @jonathan-cfmp I've raised PR https://github.com/Steams/ra-data-hasura-graphql/pull/68 which should allow for everything you've mentioned above - only getting requested fields, getting relationships etc. Let me know what you think - the README in my PR shows show it works, and I've built a small sample app: https://github.com/cpv123/react-admin-hasura-queries
It also doesn't introduce any breaking changes. I'm hoping that @Steams can take a look and have it merged if all ok.