Component with reusable business object details input question

if you have a component, which has some detailed fields for a given business object, and you want to reuse that on multiple pages in the application, what’s the right way to specify the input?

  1. Specify the business object as an input, and ensure that the calling page has all the right relationships read
  2. specify the business object and all it’s relationships, and pass the id of the business object as input, then read the need BO and relationships in an initialize method?

Both are valid approaches. The second one makes it more “black box” and the caller does not need to do much but the downside is that the client makes two (or more) calls to the API vs the single call if it is included in the parent.

You can make the first approach more bullet proof by adding logic at the top of the component checks the options on the input object to be sure that the caller did the right includes. Here is a simple example:

if (!this.myInput.getOption('include').articles) {
  throw "You must include articles."
}```