
Problem/Motivation
Gotta start somewhere...
We need to create an initial (and bare bones) ApiClient class that we can extend and build upon. This might end up being taken care of or started by way of https://www.drupal.org/project/api_client/issues/3365959 but this issue can at least be used to validate the requirements for that implementation.
Proposed resolution
The ApiClient class will take the following arguments:
* baseUrl (string)
* options (object)
To start, options will have one property, apiPrefix (string)
The class will also implement an async fetch method, that to start will just be an interface to the default fetch.
It should be possible to both create an instance of the ApiClient class, and also extend it.
Remaining tasks
* Implement the ApiClient class
* Define necessary types
* Document the current ApiClient class inline.
* Add test coverage.
API changes
The ApiClient class will be created.
Issue fork api_client-3374181
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 #3
coby.sher CreditAttribution: coby.sher at Pantheon commentedTo @jayhuskins point here: https://www.drupal.org/project/api_client/issues/3365506#comment-15098435
how can we implement this with support for localization right away?
Would that part be handled by the consumer of this library by passing in the locale to each request?
Should we require a default language like DrupalState did?
Or is the localization better handled in the JsonAPIClient instead of this base class?
Comment #4
brianperryThis is mostly addressed by our initial project scaffolding, but I think likely needs more complete tests and possibly improved documentation.
Comment #5
brianperryComment #7
brianperryOpened a draft MR with additional test coverage. Still need to take a quick look to see if anything else needs to be documented.
Comment #8
brianperryComment #9
coby.sher CreditAttribution: coby.sher at Pantheon commentedComment #10
brianperryMerged. Marking as fixed. Not sure what the deal is with the merge train failing here. Will have to keep an eye on that.