ActiveDataProvider is executing queries that I do not want

I think that problem is with fields() method.

So I have news table, and related news_comment table.

I want my REST api to return newsComment relation, but I do not want ActiveDataProvider to execute SELECT * FROM news_comments by id queries just because I have stated that I want to allow newsComment relation in output. I want to build object that is going to be returned myself.

But the problem is if I do not say in fields() method that I want ‘newsComment’ even if I make my object with it as a property of big news object I will not get it, I get only data from news table.

It seems to me here, that Yii just do not want to do what I want, it does what it wants.

I think that my goal is simple, but I do not know how to reach it.

I want my API to return news object with newsComment as a propery with the data from news_comments table. But I do not want ActiveDataProvider to execute SELECT by ID queries, I want to do that myself. Basically my ADP should just return the ID’s matching the API query request, and then I take those ID’s execute SELECT by each id and build my response myself. But the problem is with fields(). If I write newsComment there, Yii is somehow executing queries on his own, and I am using lazy loading, if I do not write newsComment in fields() Yii does not execute his own queries but I do not get newsComment in my response even if I made it there manually.

What do to ???

Is there any way to say to Yii: “Let me have in my response ‘newsComment’ relation, but also let me put it there however I want, just stop doing whatever you do” ?