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

fix: Argument type only uses scalar and ignore list #327

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions ariadne_codegen/client_generators/custom_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def generate_arguments(
arg_name,
name,
final_type,
is_required,
used_custom_scalar,
)

Expand Down Expand Up @@ -125,12 +124,11 @@ def _accumulate_return_arguments(
return_arguments_values: List[ast.expr],
arg_name: str,
name: str,
final_type: Union[GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType],
is_required: bool,
final_type: Union[GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType]
used_custom_scalar: Optional[str],
) -> None:
"""Accumulates return arguments."""
constant_value = f"{final_type.name}!" if is_required else final_type.name
constant_value = self._generate_complete_type_name(complete_type)
return_arg_dict_value = self._generate_return_arg_value(
name, used_custom_scalar
)
Expand All @@ -143,6 +141,22 @@ def _accumulate_return_arguments(
)
)

def _generate_complete_type_name(
self,
complete_type: Union[GraphQLObjectType, GraphQLInterfaceType, GraphQLUnionType, GraphQLNonNull, GraphQLList]
) -> str:
if isinstance(complete_type, GraphQLNonNull):
if hasattr(complete_type, "of_type"):
return f"{self._generate_complete_type_name(complete_type.of_type)}!"
else:
return f"{self._generate_complete_type_name(complete_type.type)}"
if isinstance(complete_type, GraphQLList):
if hasattr(complete_type, "of_type"):
return f"[{self._generate_complete_type_name(complete_type.of_type)}]"
else:
return f"[{self._generate_complete_type_name(complete_type.type)}]"
return complete_type.name

def _generate_return_arg_value(
self, name: str, used_custom_scalar: Optional[str]
) -> Union[ast.Call, ast.Name]:
Expand Down