Closed (fixed)
Project:
JSON:API Views
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
24 Feb 2020 at 02:22 UTC
Updated:
16 Oct 2021 at 09:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
pixelwhip commentedThanks! Adding arguments is definitely a feature we'll need to add.
Comment #3
artem_sylchukI've tried to add the arguments support. Unfortunately I didn't find a good way to get argument map from the request object, so I used routeMatch service, but I hope some better way to do this exists.
Also I spotted one bug, which probably can be a separate issue. I'm always getting sorting from the default display applied. For fixing that I've replaced viewExecutable route param with just a view name string and added code for loading executable in the "process" method.
Comment #4
abu-zakham commentedRe-rolled patch #3 and allowed any type of display to be have router
Comment #5
decipheredThis will need tests as it's a significant piece of functionality.
Comment #6
suresh prabhu parkala commentedIt's just a re-roll against 8.x-1.x.
Comment #7
abgeo commentedHello,
With my patch, you can pass arguments to the view using the following structure:
/{jsonapi}/views/{view_id}/{display}?views-argument[]={argument_1}&views-argument[]={argument_2}.
Comment #8
decipheredThanks @ABGEO,
It is a more consistent and simpler solution.
I still see the use case for both options though, so it might be worth collaborating and working on a combined solution?
Regardless, there absolutely needs to be tests for either of these patches to be committed, and if y’all don’t write them, I will have to, and I don’t currently have the time to do that.
Comment #9
artem_sylchukHi @Deciphered, will try to add tests, but it may take some time as I'm able to work on D.org issues only on weekend nights :)
Comment #10
abgeo commentedThanks, @Deciphered,
I will provide tests for my patch.
Comment #11
abgeo commented@Deciphered, I added some tests for this functionality.
Comment #12
goodboy commented#11 works for me
Comment #13
geek-merlin@Deciphered #8, concerning new approach in #7:
> It is a more consistent and simpler solution.
> I still see the use case for both options though
Out of interest: IMHO the #7 approach covers all use cases i can imagine, and having the other approach would only be a needless maintenance burden and more complexity to document and explain.
Can you explain why you see it useful to have both around?
Comment #14
deciphered@geek-merlin,
The approach in #7/11 relies on passing arguments via query string, but the traditional behaviour of Drupal Views (like I need to tell you) is to handle arguments by route.
Given that JSON:API Views is already defining routes for the per View display, it would sense to add more route based functionality that is consistent with the traditional Drupal behaviour.
I do agree that it is much simpler though, and I will likely opt to get #11 committed and then move the route based approach to a followup issue.
Comment #15
geek-merlin@Deciphered
Thanks, i see the point now!
Comment #16
decipheredI'm going to go ahead and commit #11, it works well and has good test coverage.
Thanks for the work, and patience.
Comment #18
decipheredComment #20
geek-merlinCool this is in!
But i think we still need the followup mentioned in #14.
Comment #21
decipheredI'm open to more work being done, and certainly stand by my reasoning in #14, but the only thing I can see that it specifically adds at the moment is code complexity.
A frontend router can still resolves routes with arguments in the URL and have it sent through to the JSON:API Views using the querystring format.
E.g.:
https://frontend.env/view/arg1/arg2->https://backend.dev/jsonapi/views/view/display?views-argument[]=arg1&views-argument[]=arg2Comment #22
geek-merlinYup, just wanted to remind, still not actively advocating or working on it.