kasia icon indicating copy to clipboard operation
kasia copied to clipboard

Use `node-wpapi` autodiscovery for custom content types

Open sdgluck opened this issue 7 years ago • 2 comments

At the moment the user is required to define explicitly the custom content types that are defined within the WP instance they are connecting to. It would be great if they could be "auto-discovered" a la node-wpapi, probably through an option.

Implementing this would require deferring calls to the WP API until the autodiscovery completed, so keeping a record internally somewhere of its completion.

sdgluck avatar Aug 10 '16 09:08 sdgluck

Thoughts for the implementer...

Changes to API:

  • configuration wpapi option should accept a Promise which should resolve with instance of node-wpapi (a la WPAPI.discover).
  • need to derive custom content types from the node-wpapi instance and register them internally so the decorators recognise them as legitimate.
  • [discussion] should contentTypes be ignored if wpapi config option receives a Promise?

Changes to internals:

  • wpapi.js: should store node-wpapi instance as a Promise regardless of whether wpapi config option is a Promise. i.e. the config option value should be passed through Promise.resolve().
  • redux/sagas.js: fetch saga should wait on resolution of the wpapi Promise. e.g. const wpapi = yield getWP() before performing the query.

sdgluck avatar Feb 01 '17 08:02 sdgluck

In progress on branch autodiscovery-support.

sdgluck avatar Feb 23 '17 12:02 sdgluck