kasia
kasia copied to clipboard
Use `node-wpapi` autodiscovery for custom content types
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.
Thoughts for the implementer...
Changes to API:
- configuration
wpapi
option should accept a Promise which should resolve with instance ofnode-wpapi
(a laWPAPI.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 ifwpapi
config option receives a Promise?
Changes to internals:
-
wpapi.js
: should storenode-wpapi
instance as a Promise regardless of whetherwpapi
config option is a Promise. i.e. the config option value should be passed throughPromise.resolve()
. -
redux/sagas.js
:fetch
saga should wait on resolution of thewpapi
Promise. e.g.const wpapi = yield getWP()
before performing the query.
In progress on branch autodiscovery-support
.