我面临的问题是我有custom_filter
哪个MyModel
返回<QuerySet>
喜欢的列表
[<QuerySet [<MyModel: xyz>]>, <QuerySet [<MyModel: xyz>, <MyModel: xyz>,<MyModel: xyz>]>]
对象类型
class MyModelNode(DjangoObjectType):
class Meta:
model=MyModel
filter_fields=['id]
interfaces = (graphene.relay.Node,)
询问
class Query(graphene.ObjectType):
my_model_items = graphene.List(MyModelNode)
def resolve_my_model_items(self, info, **kwargs):
my_model_filtered_items = MyModel.objects.custom_filter(kwargs)
# my_model_filtered_items holds the list of querysets
return my_model_filtered_items
如何处理查询集列表。查询的 graphql 响应应该给出一个列表,其中包含查询集作为元素。
[
{
//These are from first <QuerySet>
"myModelItems":[
{
"fieldsIaskedFor":"response"
}
]
},
{
//These are from second <QuerySet>
"myModelItems":[
{
"fieldsIaskedFor":"resp"
},
{
"fieldsIaskedFor":"resp"
},
{
"fieldsIaskedFor":"resp"
},
]
},
]
如何在不同的列表元素中获取不同查询集的结果?数量<QuerySet>
不固定。
我必须做些什么来实现这一目标?