Skip to content

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

Merged
merged 11 commits into from
Jan 23, 2019

Conversation

kadamwhite
Copy link
Collaborator

@kadamwhite kadamwhite commented Dec 21, 2018

The core of WPAPI is the query builder: this can be used with any HTTP library, or with native XHR or fetch. 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 default require( '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:

  • Do we continue to include 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 require wpapi/superagent?
  • Should this be wpapi/superagent (part of this repo), or a separate npm package wpapi-superagent? If the latter, it clarifies the dependency question somewhat.
  • Should we include transport options using Axios and Fetch in the core package, as well?
  • What gotcha's or issues might I be missing?

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.
@kadamwhite
Copy link
Collaborator Author

This branch can now be tested with npm install --save wpapi@alpha

@kadamwhite kadamwhite changed the title [Experiment] Separate Superagent transport into optional module Separate Superagent transport into optional module Jan 23, 2019
This functionality is not specific to superagent.
@kadamwhite
Copy link
Collaborator Author

@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 fetch and axios transports, then squash some bugs and get v2 out the door.

@Shelob9
Copy link

Shelob9 commented Jan 23, 2019

I just read the changes on my phone, looks good. I'll try to make time to test tomorrow.

@kadamwhite
Copy link
Collaborator Author

@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!

@kadamwhite kadamwhite merged commit 7f07ce4 into master Jan 23, 2019
@kadamwhite kadamwhite deleted the separate-transport branch January 23, 2019 02:11
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

Successfully merging this pull request may close these issues.

2 participants