Debugging Entity Auto Complete Field
Recently I needed to look into how the autocomplete worked with the Link field. After a lot of digging through code and step debugging, I finally figured out where the Ajax callback was and then could see how the query is put together.
The route
/entity_reference_autocomplete/{…}
is defined in /core/modules/system/system.routing.yml with the key system.entity_autocomplete. The callback is in
\Drupal\system\Controller\EntityAutocompleteController::handleAutocomplete()
From here you can figure out how the query is put together or what ever else you need to know.