Skip to content
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

Multiple filtering #19

Open
waghanza opened this issue Oct 25, 2018 · 10 comments
Open

Multiple filtering #19

waghanza opened this issue Oct 25, 2018 · 10 comments

Comments

@waghanza
Copy link

Hi @paknahad @kocsismate ,

As jsonapi spec specify it, we should be able to filter with multiple values
https://jsonapi.org/recommendations/#filtering

However, /books?filter[id]=1,2 does not show 2 books

The query generated is

SELECT t0.id AS id_1, t0.name AS name_2 FROM author t0 INNER JOIN book_author ON t0.id = book_author.author_id WHERE book_author.book_id = 1

instead of

SELECT t0.id AS id_1, t0.name AS name_2 FROM author t0 INNER JOIN book_author ON t0.id = book_author.author_id WHERE book_author.book_id in (1,2)

Regards,

@waghanza
Copy link
Author

PS : My code is publicly available https://github.com/waghanza/jsonapi-bundle-demo (my goal is to work with it as a base to improve jsonapi support in php

@paknahad
Copy link
Owner

Please take a look at this issue #5

@waghanza
Copy link
Author

👍 however, I do not understand the fact of having an external repo to enable filtering
for me filtering is already in the spec https://jsonapi.org/recommendations/#filtering
so it could be a work at yin level

what do you think ?

@waghanza
Copy link
Author

Probably we can share effort woohoolabs/yin#70

@kocsismate
Copy link

Hi! I don't think that it is a good idea to enable filtering at the framework level much more than what Yin now provides. In my opinion, Yin is only supposed to parse the filtering criteria from the request, and it's up to the application to actually use it in a DB query. Or did you mean something else?

@waghanza
Copy link
Author

waghanza commented Oct 25, 2018

Nop. It was exactly my point (after reflexion)

Sure building has to be done in this bundle

@kocsismate
Copy link

Ah I see! 👍

@mnugter
Copy link
Contributor

mnugter commented Oct 27, 2018

The JSON APi specification is actually quite unclear on the exact implementation and states "The base specification is agnostic about filtering strategies supported by a server", meaning that it does not exactly include a clear set of rules that would result in minimal and capable filtering strategy.

The examples given are extremely limited and any more complex usage of the API will find it lacking. Searching by date for example is not covered.

I created a (very) simple bridge module between this bundle and RQL:
https://github.com/mnugter/jsonapi-rql-finder-bundle

It's a drop in solution which immediately provides you with the full RQL syntax, supporting nearly everything you'd want. If you're going to access your API form Javascript I would recommend the library https://github.com/persvr/rql. I created a fork with 2 other forks merged to fix some issues and enable webpack support.

That said, I would be in favor of having this library match the given examples in the basic filtering strategy to at least match the basic filtering capabilities. I'd be happy to review any PR.

@waghanza
Copy link
Author

@mnugter You're write the specification is not very strict
https://jsonapi.org/format/#fetching-filtering

However, a requesting method is recommanded and I find this quite clear in the perspective of writing the client part 😛
https://jsonapi.org/recommendations/#filtering

@mnugter
Copy link
Contributor

mnugter commented Nov 1, 2018

To be exact: the specification does not describe the stategy and functionality. The examples are very limited in functionality and to me not well thought through. It's a nice starting point and suggestion but nothing serious when considering an advanced and capable filtering strategy.

That said: I still think that implementing the basic examples is worthwhile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants