api-platform / core

The server component of API Platform: hypermedia and GraphQL APIs in minutes
https://api-platform.com
MIT License
2.45k stars 882 forks source link

Help about ordering subresources #2775

Closed romainbriand closed 3 years ago

romainbriand commented 5 years ago

Hi!

Because of relationships between entities, there is something that I don't really understand with filters, especially built-in doctrine order filter in this case.

Here is my (abstract) scheme: GET /resources/{resourceId}/subresources

I'm getting subresources pretty well. As you can see from the screen capture below, this subresource has the order filter enabled:

image

Only problem is that the filter is not applied, and my subresources are not ordered as expected (for example if I put "desc" value in order[date] field).

What am I doing wrong? Thanks a lot in advance for your help!

coudenysj commented 5 years ago

@romainbriand Where did you define that filter? I can't get the filter working on subresources.

romainbriand commented 5 years ago

@coudenysj First, thank you so much for your reply!

I have a first config file for the "parent" resource defined in the file config/api_platform/resources/myparentresource.yaml as follow:

Blablabla\Entity\MyParentResource:
  collectionOperations:
    get:
      filters: ['search_filter']
    post: ~
  properties:
    MyChildResource:
      subresource:
        resourceClass: 'Blablabla\Entity\MyChildResource'
        collection: true
        maxDepth: 1

And then, I have another config file for the "child" resource config/api_platform/resources/mychildresource.yaml as follow:

Blablabla\Entity\MyChildResource:
  collectionOperations:
    get:
      filters: ['order_filter']

Does it help? I still think that maybe I could have done something wrong in the configuration.

soyuka commented 3 years ago

Greetings! We appreciate your concern but weren't able to reproduce this issue or it is more of a question. As described in the API Platform contributing guide, we use GitHub issues for bugs and feature requests only.

For support question ("How To", usage advice, or troubleshooting your own code), you have several options:

Feel free reach one of the support channels above. In the meantime we're closing this issue.