We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
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
In case I have below Entities:
class Book { private $id; private $title; /** * @ORM\OneToMany(targetEntity="App\Entity\Review", mappedBy="book") */ private $reviews; } class Review { private $id; private $body; /** * @ORM\ManyToOne(targetEntity="App\Entity\Book", inversedBy="reviews") */ private $book; }
When I retrieve a list of Books, I want also the total number of the reviews a book contains. The response should like below:
{ "hydra:member": [ { "@id": "/books/e0820d66-81cd-4e48-8b09-f2931a39951b", "@type": "http://schema.org/Book", "title": "345", "reviewsCount": 20 } ] }
What is the right way to implement this in API Platform?
The text was updated successfully, but these errors were encountered:
Ideally, it should be something like:
{ "hydra:member": [ { "@id": "/books/e0820d66-81cd-4e48-8b09-f2931a39951b", "@type": "http://schema.org/Book", "title": "345", "reviews": { "@id": "/books/e0820d66-81cd-4e48-8b09-f2931a39951b/reviews", "@type": "hydra:Collection", "hydra:totalItems": 20 } } ] }
Sorry, something went wrong.
Yes, it looks better. And then I found this might be related to the issue api-platform/core#1686
Closing as a solution has been found (cf. previous comment)
Ideally, it should be something like: { "hydra:member": [ { "@id": "/books/e0820d66-81cd-4e48-8b09-f2931a39951b", "@type": "http://schema.org/Book", "title": "345", "reviews": { "@id": "/books/e0820d66-81cd-4e48-8b09-f2931a39951b/reviews", "@type": "hydra:Collection", "hydra:totalItems": 20 } } ] }
hi, i'm trying to achieve this but i can't figure out how to do it. Is this possible? Where can i found some documentation about it?
No branches or pull requests
In case I have below Entities:
When I retrieve a list of Books, I want also the total number of the reviews a book contains. The response should like below:
What is the right way to implement this in API Platform?
The text was updated successfully, but these errors were encountered: