@@ -32,8 +32,9 @@ class Field:
3232 Attributes:
3333 field_type (Field.Type): The type of the field.
3434 name (str): name that the attribute has in client-side Python objects
35- grapgql_name (str): name that the attribute has in queries (and in
35+ graphql_name (str): name that the attribute has in queries (and in
3636 server-side database definition).
37+ result_subquery (str): graphql query result payload for a field.
3738 """
3839
3940 class Type (Enum ):
@@ -55,13 +56,23 @@ def name(self):
5556 return self .enum_cls .__name__
5657
5758 class ListType :
59+ """ Represents Field that is a list of some object.
60+ Args:
61+ list_cls (type): Type of object that list is made of.
62+ graphql_type (str): Inner object's graphql type.
63+ By default, the list_cls's name is used as the graphql type.
64+ """
5865
59- def __init__ (self , list_cls : type ):
66+ def __init__ (self , list_cls : type , graphql_type = None ):
6067 self .list_cls = list_cls
68+ if graphql_type is None :
69+ self .graphql_type = self .list_cls .__name__
70+ else :
71+ self .graphql_type = graphql_type
6172
6273 @property
6374 def name (self ):
64- return self .list_cls . __name__
75+ return f"[ { self .graphql_type } ]"
6576
6677 class Order (Enum ):
6778 """ Type of sort ordering. """
@@ -101,13 +112,14 @@ def Json(*args):
101112 return Field (Field .Type .Json , * args )
102113
103114 @staticmethod
104- def List (list_cls : type , * args ):
105- return Field (Field .ListType (list_cls ), * args )
115+ def List (list_cls : type , graphql_type = None , ** kwargs ):
116+ return Field (Field .ListType (list_cls , graphql_type ), ** kwargs )
106117
107118 def __init__ (self ,
108119 field_type : Union [Type , EnumType , ListType ],
109120 name ,
110- graphql_name = None ):
121+ graphql_name = None ,
122+ result_subquery = None ):
111123 """ Field init.
112124 Args:
113125 field_type (Field.Type): The type of the field.
@@ -116,12 +128,14 @@ def __init__(self,
116128 graphql_name (str): query and server-side name of a database object.
117129 If None, it is constructed from the client-side name by converting
118130 snake_case (Python convention) into camelCase (GraphQL convention).
131+ result_subquery (str): graphql query result payload for a field.
119132 """
120133 self .field_type = field_type
121134 self .name = name
122135 if graphql_name is None :
123136 graphql_name = utils .camel_case (name )
124137 self .graphql_name = graphql_name
138+ self .result_subquery = result_subquery
125139
126140 @property
127141 def asc (self ):
0 commit comments