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 inline fragments in lists #17

Merged
merged 1 commit into from
Jul 23, 2022
Merged
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
8 changes: 4 additions & 4 deletions pygraphic/_gql_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ def generate_query_lines(cls, nest_level: int = 0) -> Iterator[str]:
for field_name, field_type in fields.items():
field = cls.__fields__[field_name]
params = "".join(_gen_parameter_string(field.field_info.extra))
if typing.get_origin(field_type) is list:
args = typing.get_args(field_type)
assert len(args) == 1
field_type = args[0]
if typing.get_origin(field_type) is UnionType:
sub_types = typing.get_args(field_type)
yield " " * nest_level + field.alias + params + " {"
Expand All @@ -34,10 +38,6 @@ def generate_query_lines(cls, nest_level: int = 0) -> Iterator[str]:
yield " " * (nest_level + 1) + "}"
yield " " * nest_level + "}"
continue
if typing.get_origin(field_type) is list:
args = typing.get_args(field_type)
assert len(args) == 1
field_type = args[0]
if not inspect.isclass(field_type):
raise Exception(f"Type {field_type} not supported")
if issubclass(field_type, GQLType):
Expand Down