Maybe it's the new version of API Platform (4.1 now), but the config parameter worked for me as charm. Just where you'd written.
The main point for me was to find all ManyToMany relations )