Skip to content

Commit 45b4a20

Browse files
authored
Merge pull request #287 from bombsimon/feat/remove-global-imports-plugin
Add plugin to reduce client imports
2 parents c14dd92 + 4e06845 commit 45b4a20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+2908
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 0.14.0 (Unreleased)
44

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

78

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ Ariadne Codegen ships with optional plugins importable from the `ariadne_codegen
9696

9797
- [`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.:
9898

99+
- [`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.
100+
99101
```toml
100102
[tool.ariadne-codegen]
101103
...

ariadne_codegen/contrib/__init__.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
from .client_forward_refs import ClientForwardRefsPlugin
12
from .extract_operations import ExtractOperationsPlugin
23
from .no_reimports import NoReimportsPlugin
34
from .shorter_results import ShorterResultsPlugin
45

5-
__all__ = ["ExtractOperationsPlugin", "NoReimportsPlugin", "ShorterResultsPlugin"]
6+
__all__ = [
7+
"ClientForwardRefsPlugin",
8+
"ExtractOperationsPlugin",
9+
"NoReimportsPlugin",
10+
"ShorterResultsPlugin",
11+
]

0 commit comments

Comments
 (0)