Skip to content

Data producer paragraph_behavior is broken with NULL default value#906

Open
mrmishmash wants to merge 4 commits intothunder:7.4.xfrom
mrmishmash:thunder_gqls-paragraph-behavior-default-value
Open

Data producer paragraph_behavior is broken with NULL default value#906
mrmishmash wants to merge 4 commits intothunder:7.4.xfrom
mrmishmash:thunder_gqls-paragraph-behavior-default-value

Conversation

@mrmishmash
Copy link
Contributor

The paragraph behavior data producer as it is is broken. The default value can never be set to NULL, because if it is, the whole producer will fail and resolve to NULL, even when the behavior plugin is enabled and there is a value for the given key. Using NULL as the default value when there is no value is standard practice and as it is this cannot be done.

Throwing an exception when the plugin isn't enabled is also not ideal in my opinion. Let's say one wants to implement a behavior and fetch it on all paragraphs, even the ones that do not have it enabled, which is practical in order not to have to call it just on paragraph resolver that have it enabled, one can just enable it on a paragraph and it works if it's used in a i.e. base paragraph resolver.

Currently this isn't possible and would throw, to mitigate this, one can extend the producer and wrap the resolve() method in a try/catch block, but since paragraphs that do not have the behavior enabled will always throw, this leads to a significant performance hit because of the exception handling.

I suggest a parameter that allows the caller to determine if the producer should throw in such cases or not, with it being set to TRUE for backwards compatibility.

Make sure these boxes are checked before submitting your pull request - thank you!

  • All coding styles are fulfilled. (How to check for cs issues?)
  • All tests are running locally. (How to run the test?)
  • Necessary update hooks are provided.
  • User roles have correct access for new introduced permission.
  • Every thunder module has a README.md in its root. Follow this guidelines, but we don't need every topic.
  • Code is covered with well-balanced amount of inline comments.
  • New features or changes are documented.

If you are really awesome, then your feature is covered by additional tests. Well done!

@mrmishmash mrmishmash changed the title Fixes paragraph_behavior data producer plugin by making default value… Data producer paragraph_behavior is broken with NULL default value Sep 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants