Problem/Motivation
Currently the jsonapi client can't easily access jsonapi_views endpoints. To resolve this, either:
* JSON:API Views needs to support hypermedia (see https://www.drupal.org/project/jsonapi_views/issues/3173663)
* Or the jsonapi client could add a getView method which would allow a views endpoint to be derived without doing an index lookup.
Both would have value, but I think the client should also allow you to source views without requiring a lookup in the jsonapi index.
Steps to reproduce
* Enable jsonapi_views
* None of our existing methods will allow you to source the exposed view endpoint.
Proposed resolution
A getView method with a signature similar to getCollection
`getCollection(type, options?)`
Type in this case is a view machine name and a display_id. For example:
`getView('articles--page_1')`
This will result in a fetch request being made to `jsonapi/views/articles/page_1`
Remaining tasks
* Implement changes
* Add test coverage
* Update documentation
API changes
* Adds new getView method
Issue fork api_client-3462889
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
brianperryComment #4
brianperryCreated a draft MR with the implementation here. It doesn't include tests, as @d34dman was interested in contributing tests. This should provide a good testing overview as it requires tests for the new getView method, but also requires smaller test updates for full coverage for createUrl and createCacheKey.
Comment #5
d34dman commentedComment #6
d34dman commentedI have added some unit tests. They are just mostly making user that the urls are generated successfully. Please check :)
Comment #7
d34dman commentedComment #8
d34dman commentedThanks for the update Brian, LGTM :)
Comment #9
brianperryComment #13
brianperryMerged and released as 1.2.0