core icon indicating copy to clipboard operation
core copied to clipboard

Maximum items does not have effect for relations

Open Cruiser13 opened this issue 1 year ago • 0 comments

API Platform version(s) affected: 3.X (reproduced on 3.1.25 and 3.3.13)

Description
We have a class FileSystem that has a OneToMany relation to our class File. If we run the /filesystem endpoint we expect to get all file systems back. That works but each file system does contain the IDs of all files associated with it. That's usually above ~50.000 entries. We'd expect the pagination_maximum_items_per_page setting (set to 100) to take effect here but it doesn't. This does cause severe memory limits on server and client. We did not find any documentation to limit these related values if pagination does not work.

How to reproduce
Create a filesystem class (or any class with a OneToMany relation) and create > 10.000 related entities. It'll give you all of these entities.

#[ApiResource]
class FileSystem
{
    // .... other code

    #[ORM\OneToMany(mappedBy: 'fileSystem', targetEntity: File::class)]
    private $files;

      // .... others code
}

Possible Solution

Additional Context
Payload example screenshot with fewer relations: sample-payload

Cruiser13 avatar Oct 01 '24 20:10 Cruiser13