Custom api in strapi

For that you need to use populate with whole component selection. Go through the below query example in order to fetch each fields of collection & mentioned components.

await strapi.db.query('api::collection-name.collection-name').findOne({
  populate: ['componentName','componentName.subComponentName'] 
)}