-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: support plugin registration for the IDE #61
Conversation
- import @wordpress/icons - introduce custom webpack config for different entries. This generates different asset.php files - separate index.js and app.jsx as different entry points. index sets up some re-usable functions that can be used by 3rd party extensions, app renders the app - define WPGRAPHQL_IDE_PLUGIN_DIR_PATH and WPGRAPHQL_IDE_PLUGIN_DIR_PATH for better re-usability of directory/path definitions - split the enqueing of the index.js and app.js with the `wpgraphqlide_enqueue_script` action in between. This allows for the initial "setup" of functions to be enqueued, then extensions to be enqueued, then the app to be enqueued - add `/plugins/` directory with initial README.md - add initial plugins/help plugin to show how a 3rd party plugin could hook into the GraphiQL IDE - move the rendering of the App out of index.js into App.jsx - add "registerPlugin" function to index.js which dispatches to the store to register a plugin - update Editor.jsx to read "plugins" from the redux store and add them to <GraphiQL /> - add action/selector/reducer for registering a plugin
- ran composer fix-cs - update help cards to contain all the cards from the current help screen on the GraphiQL in the current IDE - add color variables for icon in help screen to match other icon styles
…/index.js to do "import { registerPlugin } from "wpgraphql-ide";" and it not try to import it from npm - add wpgraphql-ide to dependencies in wp_enqueue_scripts for the wpgraphql-ide-help-plugin - separate help/index.js into separate components - add css variables to the HelpCard component - add README.md to the help plugin - simplify the render of the <App />. . .turns out I was doing something stupid before when I thought I needed the addEventListener - update som docblocks/code comments - simplify some of the uses of useSelect - update the onEditQuery method of the <GraphiQL> component to ensure the redux store stays in sync - remove some console.logs
@josephfusco I pushed up a new commit cleaning up some things, adding some inline comments, adding a README.md to the help plugin, etc. Looking forward to any feedback you might have! 🙏🏻 |
|
||
module.exports = { | ||
...defaults, | ||
entry: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've ejected into a custom wepback.config.js so that each script can be enqueued seperately.
This allows us to export functions in the index.js
and enqueue them to be available in plugins and the app.
Since functions like registerPlugin
and the redux store(s) need to be available before plugins and the App call those functions, and we're not importing them via an NPM build script, we need to make sure the enqueue order has the index.js script enqueued first (as a dependency of anything that needs those functions).
@@ -70,6 +87,17 @@ const selectors = { | |||
isInitialStateLoaded: ( state ) => { | |||
return state.isInitialStateLoaded; | |||
}, | |||
getPluginsArray: (state) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now that we have determined names for each of the IDE areas, possibly this could be renamed to something like getActivityBarPlugins
instead of just plugins
🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. Feel free to make that change here if you feel inclined to, otherwise can make a separate issue to scrub the whole codebase for any other possible renames before moving on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@josephfusco let's follow-up on this.
I think we'll see some other patterns emerge re: naming things, file organization, etc as we start implementing the other "pluggable" areas
'wpgraphql-ide-app', | ||
'wpgraphql-ide', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clean!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great work @jasonbahl, and thank you for the comments and included documentation!
We may want to add test coverage to check on the window object structure just to have that explicitly called out for posterity, but since the plugin relies on those things internally, I don't feel it's absolutely critical right now.
What this does:
This allows 3rd party plugins to "registerPlugin" to the WPGraphQL IDE.
ex:
help.php
help.js
Would output the following:
In fact, you can actually see this example plugin built-in to this PR:
see the
./plugins/help
directory!Summary of this PR:
wpgraphqlide_enqueue_script
action in between. This allows for the initial "setup" of functions to be enqueued, then extensions to be enqueued, then the app to be enqueued/plugins/
directory with initial README.md