Skip to content
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

[core] Add an option for disallowing useOnResolve usage #2225

Open
EmrysMyrddin opened this issue May 2, 2024 · 0 comments
Open

[core] Add an option for disallowing useOnResolve usage #2225

EmrysMyrddin opened this issue May 2, 2024 · 0 comments

Comments

@EmrysMyrddin
Copy link
Collaborator

EmrysMyrddin commented May 2, 2024

Context

In the past, Envelop allowed to hook into the execution at resolver level, meaning plugin was able to replace or wrap any resolver.
This was causing performance issues, since wrapping every resolver added a significant overhead.

To circumvent this issue, we removed this onResolve hook and replaced it by a plugin useOnResolve, which wraps each resolvers only when used, meaning other users doesn't have perf issues for this feature.

But it turns out we think this should not be part of Envelop at all. Envelop is meant as a runtime plugin system. This means that schema modifications should happen at schema build time, and wrapping resolvers is a schema modification.

Since this change is a breaking change and will need the refactoring of multiple plugins, it will takes time. Meanwhile, we should allow users or library maintainers using Envelop to enforce the fact the schema is not mutated during Envelop execution.

Solution

Add an option to Envelop to globally disallow the usage of useOnResolve. If this option is enabled, useOnResolve should throw a comprehensive error. It could also be a good thing to make this error message configurable, so that library maintainers can explain why this plugin is disallowed.

Alternatives

An alternative could be to freeze the schema object. But this has a cost, and the error will not be clear from a user perspective.

Additional context

This is not a perfect solution, but it's mean to gracefully guide users and library maintainers towards the removal of useOnResolve.

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

No branches or pull requests

1 participant