我正在使用Django和Graphene并且有多个级别我想要过滤。但我无法通过“未知操作命名”未定义\“。”或者在层次结构的每个级别获取所有对象(即:为每个作业列出的所有作业的所有jobDetails)。
我正在尝试执行此查询:
query {
allPushes(revision: "1ef73669e8fccac35b650ff81df1b575a39a0fd5") {
edges {
node {
revision
author
jobs (result: "testfailed") {
edges {
node {
result
jobDetails (url_Iendswith: "errorsummary.log") {
edges {
node {
url
}
}
}
}
}
}
}
}
}
}
在Django中,jobDetails
有jobs
的外键,其外键为pushes
我的第一次尝试是设置我的节点:
class JobDetailNode(DjangoObjectType):
class Meta:
model = JobDetail
filter_fields = {
'url': ('exact', 'icontains', 'iendswith')
}
interfaces = (relay.Node, )
class JobNode(DjangoObjectType):
class Meta:
model = Job
filter_fields = ('result', 'tier')
interfaces = (relay.Node, )
job_details = DjangoFilterConnectionField(JobDetailNode)
class PushNode(DjangoObjectType):
class Meta:
model = Push
filter_fields = ('revision', )
interfaces = (relay.Node, )
jobs = DjangoFilterConnectionField(JobNode)
但正如我所说的那样,对于每个工作,所有jobDetails
都会返回,而不仅仅是属于该工作的jobDetails。
但是,如果我删除那些DjangoFilterConnectionField
字段,那么我无法在每个级别进行过滤;只是第一个。
我的查询如下所示:
class Query(ObjectType):
all_pushes = DjangoFilterConnectionField(PushNode)
all_jobs = DjangoFilterConnectionField(JobNode)
all_job_details = DjangoFilterConnectionField(JobDetailNode)
def resolve_all_pushes(self, args):
return Push.objects.filter(**args)
def resolve_all_jobs(self, args):
return Job.objects.filter(**args)
def resolve_all_job_details(self, args):
return JobDetail.objects.filter(**args)
有关如何在多个级别设置过滤的任何建议吗?在此先感谢!!