Can I create a block with Link that automatically gets all records?

As an example letā€™s say I have a Model ā€œUpdatesā€ with some text field.

Now I have a Model of ā€œPageā€ and is some pages I want to include a ā€œupdates dummy blockā€ that will fetch all the ā€œUpdatesā€ that exists.

The reason is that I fetch all Pages with querying the field ā€œURLā€ of that page, and I donā€™t know in advance if I need the ā€œUpdatesā€ as well.

I could do another fetch once I know if the page has the ā€œupdates dummy blockā€ but this is becoming cumbersome quickly once I have multiple things like ā€œUpdatesā€.

Hi @segel,

Welcome to Dato, and sorry for the delayed response on this! I was away on vacation, and posts categorized as Feature Requests donā€™t get seen as quickly. My apologies.

Anyway, to answer your question, it would be cumbersome to do this within the DatoCMS UI itself (the admin area that you use to edit things).

We donā€™t really have a ā€œlink to ALL records of another modelā€ function by default, only pickers that let you choose specific ones. You can possibly make one using webhooks or plugins, but I wouldnā€™t recommend it.

Instead, this should be very easy to do on your frontend via GraphQL. You can even do it in the same GraphQL call, like this:

query MyQuery {
  
  page(filter: {id: {eq: "myPage"}}) {
    id
    title
  }
  
  allIngredients(first: 100) {
    id
    title
  }

}

That will get you the page you want, along the IDs and titles of all the ingredients. You donā€™t need to make any blocks in the UI, even.

Does that help at all? If Iā€™m misunderstanding your use case, could you please provide a more detailed example?

Thanks, and sorry again for the slow reply!