product-roadmap icon indicating copy to clipboard operation
product-roadmap copied to clipboard

Expose inverse relations in Dashboard and GraphQL API

Open sedubois opened this issue 6 years ago • 7 comments

If I have a Post model with a category property of type PostCategory, it allows me to easily display the post's category when querying for a specific post: datoCmsPost(...) { category { ... } } (this is the syntax of gatsby-source-datocms).

To do the opposite and create a page with all posts of a specific category, currently I have to query all posts and add a filter to select only the relevant category: allDatoCmsPost(filter: { category: { ... } }) { ... }.

However:

  • deep filtering doesn't work, so I can't filter by a sub-property of the category (see https://github.com/datocms/gatsby-source-datocms/issues/34)
  • from a semantic point of view it would be more logical to just query datoCmsCategory(...) { posts { ... } }.

So it would be great if, when creating the Post's category property in the dashboard, we could expose the inverse relation as well. (Kind of equivalent to belongs_to :parent_model, inverse_of: :model in ruby on rails.) This inverse relation would be visible/navigatable in DatoCMS' dashboard and in the GraphQL API and gatsby-source-datocms API.

sedubois avatar Oct 07 '18 12:10 sedubois

We are currently looking into GraphQL headless CMSs and deep filtering is the major missing piece for us in DatoCMS. GraphCMS and others have this ability but we much prefer DatoCMS interface and flexibility. Are there any plans to make this happen?

flippidippi avatar Nov 19 '18 14:11 flippidippi

"is the major missing piece" -Absolutly!

SergeyRe avatar Nov 19 '18 23:11 SergeyRe

We're actively working on deep filtering.. should be ready in the next 2 weeks!

stefanoverna avatar Nov 20 '18 09:11 stefanoverna

are there some updates for this issue?

kainbacher avatar Dec 06 '18 15:12 kainbacher

Any updates on deep filtering?

flippidippi avatar Dec 15 '18 17:12 flippidippi

We'll track the deep filtering feature into a new issue: https://github.com/datocms/product-roadmap/issues/128

stefanoverna avatar Jan 15 '19 13:01 stefanoverna

This feature request has been moved to https://community.datocms.com/t/313

matjack1 avatar Sep 18 '19 15:09 matjack1