-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Do we need a plugin architecture and what does it look like? #1489
Comments
List Plugin API ProposalIn this comment I'll outline a proposal for adding A new field will be added to the The plugin function can make changes such as adding new fields or hooks, adding new options to existing fields (e.g. adding access control), or modifying existing fields. A trivial example would be keystone.createList('User', {
fields: { ... },
hooks: { ... },
plugins: [config => ({...config, fields: { ...config.fields, newField: { type: Text })],
}
The following two pieces of code would be equivalent. keystone.createList('User', {..., plugins: [plugin1, plugin2] }) keystone.createList('User', plugin2(plugin1({...}))) In this sense, the |
@timleslie on Hooks, is this possible to modify existing hooks config item to also accept array and run them async as part of this PR? (we discussed over slack). instead of plugin wrap the field hook in async they can push to hooks like 'field.hooks.push(async () => {})` |
Changing the hooks API is out of scope for this API. It's definitely still on the radar though, I think the appropriate pattern will land once we get this plugin API taken care of and a few different types of plugins start to come in. |
makes sense. for the help of community with plugins, I strongly feel that we should delay any initialization of field or list from config until the call to |
I'm not sure I understand the desire for this. Can you give an example of a use case where it would be useful to do something "uninitialized" state? |
@timleslie I have taken another look. One of the use case is to add fields later by things like Auth Strategies, right now if you want to capture social auth username into User collection, You have to do it manually in schema. If we delay edit: created another issues #1498 for this |
It looks like there hasn't been any activity here in over 6 months. Sorry about that! We've flagged this issue for special attention. It wil be manually reviewed by maintainers, not automatically closed. If you have any additional information please leave us a comment. It really helps! Thank you for you contribution. :) |
It seems there is a need for some kind of plugin architecture. Sometimes this can be achieved via hooks and HOC however if there are many popular 'plugins' wrapping many HOCs is not a fantastic API.
I've created this issue to discuss.
Some examples that might be 'plugins' include:
Audiences
as access control roles + multiple GraphQL schemas #1273keystone.createItems
should validate data against the schema before insertion #139, [WIP] Remove createItems #1091I'm very pro plugins as I think they help find limitations in the core product. An example of this is orderable\sortable fields. To support this I think we need to make some changes to the core platform and if other plugin ideas surface requirements that would be great!
I'd love to see 'plugins' stay really simple. essentially a better API for HOCs something like:
I think plugins should be able to add fields, add hooks and register their own hooks.
The text was updated successfully, but these errors were encountered: