我想通过使用以下查询在 graphiql 中创建一个家具对象,其中出现错误Cannot query field "furniture" on type "RootMutation"。
这是我为创建家具对象所做的查询
mutation {
newFurniture(input: {name: "graphFurniture", content: "This furniture is cool", category: "Bedroom Items"}) {
clientMutationId
}
furniture{ // error is shown here
name
content
category {
name
}
}
}
这是我的突变代码
class FurnitureNode(DjangoObjectType):
class Meta:
model = Furniture
class NewFurniture(graphene.ClientIDMutation):
furniture = graphene.Field(FurnitureNode)
class Input:
name = graphene.String()
content = graphene.String()
category = graphene.String()
@classmethod
def mutate_and_get_payload(cls, input, context, info):
furniture = Furniture(name=input.get('name'), content=input.get('content'),
category=Category.objects.get(name=input.get('category')))
furniture.save()
return NewFurniture(furniture=furniture)
class NewFurnitureMutation(graphene.ObjectType):
new_furniture = NewFurniture.Field()
为什么我会收到这样的错误?