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

Add plugin to reduce client imports #287

Merged
merged 11 commits into from
Apr 3, 2024
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 0.14.0 (Unreleased)

- Added `ClientForwardRefsPlugin` to standard plugins.
- Re-added `model_rebuild` calls for input types with forward references.


Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ Ariadne Codegen ships with optional plugins importable from the `ariadne_codegen

- [`ariadne_codegen.contrib.extract_operations.ExtractOperationsPlugin`](ariadne_codegen/contrib/extract_operations.py) - This extracts query strings from generated client's methods into separate `operations.py` module. It also modifies the generated client to import these definitions. Generated module name can be customized by adding `operations_module_name="custom_name"` to the `[tool.ariadne-codegen.operations]` section in config. Eg.:

- [`ariadne_codegen.contrib.client_forward_refs.ClientForwardRefsPlugin`](ariadne_codegen/contrib/client_forward_refs.py) - This plugin changes generated client module moving all Pydantic models imports under the `TYPE_CHECKING` condition, making them forward references. This greatly improves the import performance of the `client` module.

```toml
[tool.ariadne-codegen]
...
Expand Down
8 changes: 7 additions & 1 deletion ariadne_codegen/contrib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from .client_forward_refs import ClientForwardRefsPlugin
from .extract_operations import ExtractOperationsPlugin
from .no_reimports import NoReimportsPlugin
from .shorter_results import ShorterResultsPlugin

__all__ = ["ExtractOperationsPlugin", "NoReimportsPlugin", "ShorterResultsPlugin"]
__all__ = [
bombsimon marked this conversation as resolved.
Show resolved Hide resolved
"ClientForwardRefsPlugin",
"ExtractOperationsPlugin",
"NoReimportsPlugin",
"ShorterResultsPlugin",
]
Loading
Loading