Error when having relations with an intermediary class (table) that is not a resource
API Platform version(s) affected: 3.1.7
Description
I have a model Model1 with a relation manyToOne with a model Model1Model2 which have a relation manyToOne with the model Model2.
I have a resource (in an XML file) on the Model1 using a normalization context with a group which retrieve informations from Model1Model2 and Model2.
When I create a resource for the Model2 (get item and get collection operations), it generates an error on the Model1 get collection > "Unable to generate an IRI for the item of type ..."
I could resolve the problem by creating the resource (with only the get item operation) on Model1Model2. But it forces me to create an API that I don't need.
How to reproduce
Create a model Model1 with a relation manyToOne with a model Model1Model2 which have a relation manyToOne with the model Model2.
Create a resource on the Model1 using a normalization context with a group which retrieve informations from Model1Model2 and Model2.
Create a resource for the Model2 (get item and get collection operations).
You need to have multiple lines in your database tables.
Possible Solution
X
Additional Context
In class src/Symfony/Routing/IriConverter.php (method getIriFromResource) it is trying to generate an IRI for Model2 using the get operation of Model1.
And it works when it is trying to generate the IRI for the first Model2 (the first time the $operation parameter is null but not the second time).