我想在 Saleor 中添加新功能产品 QA。我启动了一个新应用程序“QA”并创建了一个模型来存储此信息,例如产品信息、员工用户、QA 状态和 QA 日期。我创建 grqaphql API 来添加数据,但是当我尝试获取产品信息时,它反映了“AttributeError:'Product' 对象没有属性'node'”
这是我的模型
class QA (models.Model):
product = models.ForeignKey(Product, related_name="product", on_delete=models.CASCADE)
qa_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True , blank=True)
qa_status = models.CharField(max_length=10, choices=STATUS_CHOICE, default="Pending")
qa_date = models.DateTimeField(null=True , blank=True)
这是我的 Graphql 突变
class QAType(CountableDjangoObjectType):
class Meta:
interfaces = [graphene.relay.Node]
model = QA
fields="__all__"
class ProductQAInput(graphene.InputObjectType):
product = graphene.ID(description="Product ID.", required=True)
qa_by = graphene.ID(description="Staff User ID.", required=True)
qa_status = graphene.String(description="QA Status if changed .")
qa_date = graphene.String(description="QA Date .")
class CreateProductQA(ModelMutation):
class Arguments:
input = ProductQAInput(
description="Fields required"
)
class Meta:
description = " QA."
model = QA
error_type_class = QAError
error_type_field = "qa_errors"
@classmethod
def perform_mutation(cls, _root, info, **data):
response = super().perform_mutation(_root, info, **data)
return response
mutation{
createProductQA(input:{product:"UHJvZHVjdDo2MQ==", qaBy:"VXNlcjo5NjM="}){
qA{
id
product{
id
name
}
qaBy{
id
email
}
}
}
}