(Ignoring the bit where 'queryGenres()' returns an object an always empty 'movies' property to be filled in vs a new object with genre + movie )
Yes this will work -- or something close. It may not perform optimally depending on the characteristics of the 2 APIs - this query each genre one by one.
You mention the database returns a Flow but your function signature is List.
You are missing the 'collect' part.
As written the function will not compile.
If you want to return a List then change the map to collectToList()
or add a .toList()
However that will not complete until all genere's are queried.
You an return the flow directly, if your calling code can read flows - then they would get each genre (with movie list) one a time.