From 7e320e8c77c12ad3fcfa64f3aad4428ad1068539 Mon Sep 17 00:00:00 2001 From: 0xMochan Date: Tue, 16 May 2023 08:26:18 -0700 Subject: [PATCH] fix: nested orderBy working with DSL --- subgrounds/subgraph/fieldpath.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/subgrounds/subgraph/fieldpath.py b/subgrounds/subgraph/fieldpath.py index 2ab0ffe..7302ef4 100644 --- a/subgrounds/subgraph/fieldpath.py +++ b/subgrounds/subgraph/fieldpath.py @@ -230,6 +230,7 @@ def fieldpaths_of_object( yield subgraph.__getattribute__(object_.name).__getattribute__( fmeta.name ).id + case _: yield subgraph.__getattribute__(object_.name).__getattribute__( fmeta.name @@ -456,13 +457,11 @@ def fmt_arg(name, raw_arg): case ("where", [Filter(), *_] as filters): return Filter.to_dict(filters) case ("orderBy", FieldPath() as fpath): - match fpath._leaf: - case TypeMeta.FieldMeta() as fmeta: - return fmeta.name - case _: - raise Exception( - f"Cannot use non field {fpath} as orderBy argument" - ) + if paths := fpath._name_path(): + return "__".join(paths) + raise Exception( + f"Cannot use empty paths as orderBy argument {fpath}" + ) case _: return raw_arg