Closed jamesdh closed 3 years ago
This is especially relevant to #64 since I'm noticing that by supplying a custom dataFetcher on a field that already exists in the graph, you automatically go from having a single query to a minimum of two, and possibly many more if it's a 1-to-Many association.
Currently, if you supply your own dataFetcher for a given field, the GORM database query gets delineated at the point of that dataFetcher. The original query is executed as if the custom dataFetcher was not even provided (to the extent that the fields being queried were already part of the graph), and then any queries performed within the custom dataFetcher are executed in addition to that.
In the case of a deep object graph, with 1-to-Many associations and with potentially multiple custom dataFetchers, this becomes inefficient very quickly. It should be possible that instead we simply pass the unexecuted DetachedCriteria along to a deeper custom dataFetcher. That in turn could use DetachedCriteria's query composition abilities to modify the original query, so on and so forth, ultimately resulting in one single, efficient query.