-
Notifications
You must be signed in to change notification settings - Fork 35
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
Improve Import Speed #329
Comments
I guess another option could be a "InputTypeStore" or "ModelStore", where |
I think a plugin could be written but maybe this should just be the default behavior. If an input type isn't used in the generated client it makes no sense to generate it. In fact, I thought this was how the generator worked today but maybe it always generates the full schema regarding types? One issue is that Python doesn't allow you to split classes into multiple files and because of that I think the issues got closed and the topic was somewhat dropped due to pydantic/pydantic#6748 which confirms that this is an issue with Pydantic and especially since upgrading to v2. Luckily there's been some progress lately it seems like and they're working to improve the speed of Pydantic which would have a direct impact of the generated code from this project. |
This issue is known and on our minds to fix but it'll take a while. In the meantime did you try to use: [tool.ariadne-codegen]
...
include_comments = "none"
include_all_inputs = false
include_all_enums = false
plugins = [
...
"ariadne_codegen.contrib.client_forward_refs.ClientForwardRefsPlugin",
"ariadne_codegen.contrib.no_reimports.NoReimportsPlugin",
] This greatly reduces the import time (as there's just that much less code). |
Related: #233
Related: #226
Background:
This isn't a new issue. Like others, I am experiencing some pretty slow imports when generating code based on my schema. We use Hasura and typically just export the full schema for other apps to use for codegen.
For us + Hasura specifically, it's the
input_types
that have the longest import time, with the calls tomodel_rebuild
at the bottom of the file being the cause. The plugin from this comment does help a ton.For reference, in our case,
input_types
ends up about 4k lines w/ about 300 lines ofmodel_rebuild()
calls.Feature idea:
I noticed that all input types are always generated, despite our code only using a few of them.
I also noticed that the
client.py
file only imports the input types it needs for the actual client.Since the codegen is already able to detect only what input types are actually needed, would it make sense to use the same logic to only generate types that are actually required? Or maybe support writing all input types to their own files within a directory, then only import what you require?
Is it possible to make something like that with a plugin?
The text was updated successfully, but these errors were encountered: