How does the backend ensure complex queries are efficient and that the client can't make a costly query without realizing it?
What they do is coalesce all those separate queries into one, and actually allow for sub-query optimisations if you feel like it.
So the answer is that it does not, any more than e.g. grpc does not.
I'm guessing typical implementations would involve a lot of caching.
It would be nice to hear about people's experiences though.