Questions on plugin update

default discord avatar
Ontopic3 years ago
2 2

If I understand correctly we have since the last update the sanitising of the (POJO) config first, then the plugin functions pipe through the sanitised config, finally that result is sanitised again. Did I get this part right?

If so;

  1. Could I remove collections in any of the step to keep them available for Payload, but hidden in the admin? (f.e. after the first sanitisation)
  2. What will happen with defaultValues if I change them in the plugin phase?
  3. Changing the name or type of fields, will hell break loose?
  • Selected Answer
    discord user avatar
    jmikrut
    3 years ago

    Hey @Ontopic — we've actually updated this a bit since you opened this discussion.

    The order of operations is now:

    1. Config is fully validated
    2. Plugins are initialized
    3. Default values are loaded into config and the config is fully sanitized

    Here are some answers to your questions directly:

    1. You can certainly remove collections, but hiding them from the admin panel is actually a feature that we would need to build yet. There would be a few things to consider, such as relationship fields that might point to a hidden admin collection, but this could theoretically be a new feature. In any case, you can certainly remove / add collections with plugins. Now... hiding them from the admin UI, that's a new feature.
    2. You can change field defaultValues as much as you want in the plugin phase! The resulting config will feature all defaultValues as they have been set in plugins. Nothing is actually executed until after all plugins are initiated.
    3. As with the last answer, you can also change the name of fields. You might not want to go and hijack a user's config unless they explicitly understand the ramifications, but technically, you can do whatever you want to their config, totally including changing field names.
  • default discord avatar
    Ontopic3 years ago

    The magnitude of this change is understated in my opinion, btw. The ability (together with the Typescript types tuning) allows for a lot of flexibility in trying out a weird new feature without touching your "clean" code or make last-minute changes before a presentation 😇. Although a bit hacky, that can always be cleaned up later.

    1 reply
    discord user avatar
    jmikrut
    3 years ago

    Absolutely. There is a ton of power here. Really pumped to see how people are already using it.

Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.