-
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
add PrependPlugin #1839
add PrependPlugin #1839
Conversation
related: 99designs#1838
Thanks for your work on this. Can you please add test coverage for your new PrependPlugin? It seems like to make the modelgen documentation example work we do need AppendPlugin functionality as mentioned by @Erwin-k in #1717. |
@StevenACoffman I don't know why you are of the opinion that it is unresolved. Obviously, the default should be the behavior before the breaking change occurs. It works on all versions except v0.15
I'm going to write a test for PrependPlugin, but I think that reverting the AddPlugin function should be done as soon as possible. (Regardless of the test) |
@Code-Hex I don't remember it exactly anymore but at the time I pushed this change it seemed that the plugins were being used in reverse order (by gqlgen). The former plugins would overwrite results of latter plugins (in the array), so prepending plugins would give desired behaviour for user using "addPlugin". Atleast that was what I thought was happening. @StevenACoffman perhaps it only applied to the modelgen hook or something? I noticed the documentation for modelgen is using "replacePlugin" now. |
@Erwin-k Even if this were the case, it would not be a reason to implicitly change the behavior already provided in other versions.
Look at the API provided by Go itself. Create new APIs without breaking the logic already provided. Always use the "Deprecated" comment even if you are going to deprecate. |
While avoiding breaking compatibility with existing usage is always the goal, mistakes happen. As mentioned in #1717 at the time I deemed it unlikely that anyone was relying on behavior that had changed from even earlier releases. These changes had then caused the documented example to fail. It also seemed that Thanks to your work, people can now explicitly choose the behavior that they want. We can improve documentation on whether or not the plugins are applied in reverse/forward order (PRs welcome). Please further consider contributing test cases for any uncovered areas of the code that you would like to avoid us unintentionally breaking compatibility with. I am sorry for any inconvenience this may have caused you. Please also grant fellow open-source contributors the benefit of assuming only the best of intentions. I will make a new v0.16.0 release with these changes shortly. |
This PR should only be merged after #1838 is merged. #1838 reverts #1717
gqlgen/api/generate.go
Lines 21 to 32 in 8b25c9e
func PrependPlugin
I have: