How to dynamically fill a relation field inside a component

What I have:

  • A collection type “Articles”
  • A collection type “Category of article”
  • A single type “a page”
  • A single type “another page”
  • A component “Articles section”

I’d like to populate my “Articles section” component with the last 3 articles of a selected category. I’d like to be able to put the component on the first page and just select a category of articles, put it also on the second page with a different category of articles, but do not pick the articles myself.

Is there a way to do that? I haven’t found a way to customize what a component or field returns, like you could with a collection.