-
-
Notifications
You must be signed in to change notification settings - Fork 957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Duplicate ressources in ManyToMany relations #799
Comments
@guilhemVB I open PR in api-platform/core |
todo before closing: Add a behat test in api-platform/core for this particular behavior |
Hi guys! I got the same issue, do you have an idea how we can fix it? |
solution is to simply disable the eager loading feature or build your own query. I'm really not sure how we could fix this otherwise... For the #799 example: /**
* @ApiResource(
* attributes={"normalization_context"={"groups"={"order_read", "customer_read", "address_read"}}, "force_eager"=false}
* )
* @ORM\Entity
* @ORM\Table(name="`order`")
*/
class Order
{
} |
@soyuka, if I'll set |
Everything will work, this just skips the magic in building queries based on what you want to retrieve. Basically EagerLoading in api platform builds the sql query with JOINs where it can. By disabling it you'll keep the default doctrine behavior which, in this case, is more appropriate (lazy loading). |
@soyuka , thanks, I'll disable force_eager system-wide in api-platform configuration. should be fine I believe. |
You can also disable it per-operation or per-resource wise see https://api-platform.com/docs/core/performance/#force-eager |
Hi,
I've a problem with serialization groups and ManyToMany relations in sub ressoucres.
I've a Entity "Order" with one attribute CustomerBy (ManyToOne to entity "Customer") and one attribute CustomerFor (ManyToOne to entity "Customer" too).
Customer have an attribute addresses (ManyToMany to entity Address)
When Order have the same Customer in "CustomerBy " and "CustomerFor", all the addresses are duplicated:
Order:
Customer:
Address:
When I send a GET request to
/api/orders/1
I've the following result:You can see that all "addresses" are duplicated :/
Did I miss something or is it a bug ?
My Api-platform version:
Thanks
The text was updated successfully, but these errors were encountered: