-
Notifications
You must be signed in to change notification settings - Fork 191
Separate Superagent transport into optional module #409
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
Conversation
Converts all integration tests to use `describe.each` so they can be run against the existing superagent-based HTTP transports, as well as hypothetical future transports using isomorphic-fetch or axios.
This branch can now be tested with |
This functionality is not specific to superagent.
@Shelob9 Fancy a quick code review? If I can get one pair of 👀 then we can land this and I'll move on to implementing the |
I just read the changes on my phone, looks good. I'll try to make time to test tomorrow. |
@Shelob9 🙌 Thanks much! I appreciate the initial review. To keep things moving I'm going to merge this now, but if and when you see any issues in testing, please open them as separate tickets, and I'll prioritize! |
The core of
WPAPI
is the query builder: this can be used with any HTTP library, or with native XHR orfetch
. It seems odd therefore that we require superagent no matter how you intend to use the library.This WIP / Experimental PR creates a new module you can use via
require( 'wpapi/superagent' )
, to pull in the WPAPI object configured with a Superagent-specific http transport object. This is a breaking change, because it means that by defaultrequire( 'wpapi' )
will yield an object incapable of making HTTP requests; but it sets us up for a lot of flexibility down the road.Input welcome on this proposal, and more to follow after the holidays!
Open questions:
superagent
as a dependency, or make it a peerDependency or drop it as a dependency altogether, instead instructing users they must install it if they wish to requirewpapi/superagent
?wpapi/superagent
(part of this repo), or a separate npm packagewpapi-superagent
? If the latter, it clarifies the dependency question somewhat.