-
Notifications
You must be signed in to change notification settings - Fork 36
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
black.parsing.InvalidInput: Cannot parse: 1041:8: def return(cls, id: str) -> ReturnFields: #319
Comments
Seems like here is the problem, they have query named |
OH MY! Same issue here. Is there a workaround? |
Here's what I did:
Now I'm getting a different error: Selected strategy: Strategy.CLIENT
Using schema from 'path/to/graphql_schemas/shopify.admin.2024-07.graphql'.
Reading queries from ''.
Using 'graphql' as package name.
Generating package into 'library/shopify/'.
Using 'AdminClient' as client name.
Using 'AsyncBaseClient' as base client class.
Coping base client class from '/usr/local/lib/python3.12/site-packages/ariadne_codegen/client_generators/dependencies/async_base_client.py'.
Generating enums into 'enums.py'.
Generating inputs into 'input_types.py'.
Generating fragments into 'fragments.py'.
Comments type: stable
Converting fields and arguments name to snake case.
Generating async client.
No files to copy.
Plugins to use: ariadne_codegen.contrib.client_forward_refs.ClientForwardRefsPlugin,ariadne_codegen.contrib.no_reimports.NoReimportsPlugin
Traceback (most recent call last):
File "/usr/local/bin/ariadne-codegen", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ariadne_codegen/main.py", line 37, in main
client(config_dict)
File "/usr/local/lib/python3.12/site-packages/ariadne_codegen/main.py", line 81, in client
generated_files = package_generator.generate()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ariadne_codegen/client_generators/package.py", line 171, in generate
self._generate_client()
File "/usr/local/lib/python3.12/site-packages/ariadne_codegen/client_generators/package.py", line 257, in _generate_client
client_module = self.client_generator.generate()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ariadne_codegen/client_generators/client.py", line 148, in generate
module = self.plugin_manager.generate_client_module(module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ariadne_codegen/plugins/manager.py", line 60, in generate_client_module
return self._apply_plugins_on_object("generate_client_module", module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ariadne_codegen/plugins/manager.py", line 40, in _apply_plugins_on_object
modified_obj = method(modified_obj, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/ariadne_codegen/contrib/client_forward_refs.py", line 91, in generate_client_module
self._insert_import_statement_in_method(method_def)
File "/usr/local/lib/python3.12/site-packages/ariadne_codegen/contrib/client_forward_refs.py", line 184, in _insert_import_statement_in_method
module=self.imported_classes[import_class_id],
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 'self' Disabling the |
This root cause: diff --git a/ariadne_codegen/client_generators/custom_operation.py b/ariadne_codegen/client_generators/custom_operation.py
index f9ee64f..d9c4d69 100644
--- a/ariadne_codegen/client_generators/custom_operation.py
+++ b/ariadne_codegen/client_generators/custom_operation.py
@@ -22,7 +22,7 @@ from ..codegen import (
generate_return,
)
from ..plugins.manager import PluginManager
-from ..utils import str_to_snake_case
+from ..utils import process_name
from .arguments import ArgumentsGenerator
from .constants import (
ANY,
@@ -137,8 +137,14 @@ class CustomOperationGenerator:
return_arguments_keys, return_arguments_values
)
+ processed_name = process_name(
+ operation_name,
+ convert_to_snake_case=self.convert_to_snake_case,
+ plugin_manager=self.plugin_manager
+ )
+
return generate_method_definition(
- name=str_to_snake_case(operation_name),
+ name=processed_name,
arguments=method_arguments,
return_type=generate_name(return_type_name),
body=[
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fails when trying to generate Sync client for Shopify GraphQL, but works fine with
enable_custom_operations=false
env:
The text was updated successfully, but these errors were encountered: