Skip to content

Commit

Permalink
Merge pull request #287 from bombsimon/feat/remove-global-imports-plugin
Browse files Browse the repository at this point in the history
Add plugin to reduce client imports
  • Loading branch information
rafalp authored Apr 3, 2024
2 parents c14dd92 + 4e06845 commit 45b4a20
Show file tree
Hide file tree
Showing 56 changed files with 2,908 additions and 1 deletion.
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__ = [
"ClientForwardRefsPlugin",
"ExtractOperationsPlugin",
"NoReimportsPlugin",
"ShorterResultsPlugin",
]
Loading

0 comments on commit 45b4a20

Please sign in to comment.