question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Do we need a plugin architecture and what does it look like?

See original GitHub issue

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:

I’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:

keystone.createList('User', Users, 
{ 
plugins: [
  withTimestamps(timestampPluginOptions), 
  withRoles(rolePluginOptions), 
  ]
}
);

I think plugins should be able to add fields, add hooks and register their own hooks.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:7 (6 by maintainers)

github_iconTop GitHub Comments

7reactions
timlesliecommented, Aug 13, 2019

List Plugin API Proposal

In this comment I’ll outline a proposal for adding list plugins as a mechanism for adding functionality to a List.

A new field will be added to the config object consumed by createList called plugins, which takes a list of functions with the signature config => config. Each of these functions will have an opportunity to take the config object and return either a new config or a modified config.

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 })],
}

createList would apply each of the plugins in the order specified, allowing for chaining of different plugins.

The following two pieces of code would be equivalent.

keystone.createList('User', {..., plugins: [plugin1, plugin2] })
keystone.createList('User', plugin2(plugin1({...})))

In this sense, the plugins option is simply a convenience wrapper around what is already possible. The advantage is that it gives us a well defined pattern which people can follow. It also allows the plugin list to be defined programatically.

0reactions
stale[bot]commented, Feb 15, 2020

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. 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plug-in Architecture. and the story of the data pipeline…
The plug-ins are stand-alone, independent components that contain specialized processing, additional features, and custom code that is meant to ...
Read more >
What is Plugin Architecture? - dotCMS
Plugins are a cohesive, self-contained unit whose dependencies to other components and services are already predefined.
Read more >
Plugin architecture
The Plugin architecture pattern consists of two types of architecture components: a core system and plug-in modules. Application logic is divided between ...
Read more >
Plug-in Architectures - Apple Developer
Plug-in Architectures. This section describes how to architect an application for extensibility through plug-ins. If you want to make your ...
Read more >
Designing a plugin architecture for an application
One way to prevent this is to design a plugin architecture from the start - and to continually ask yourself the question whether...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found