온라인으로 튜토리얼을 작성하고 graphql
에 mutation
이 작동하도록하려고하지만 오류가 계속 발생합니다. 어디에서 실제 오류가 발생하는지 그리고 내가 잘못한 곳에서 디버깅을 시작하는 방법에 대해 알지 못합니다. 나는 내가 youtube
돌연변이 오류, "돌연변이"유형의 "createProduct "필드에 알 수없는 인수 "바코드 "- django
정확히 따르는 대신 문서를 읽는 이유 때문에 다른 그래 핀 버전, 즉 것으로 나타났습니다 http://docs.graphene-python.org/en/latest/types/mutations/
돌연변이 https://www.youtube.com/watch?v=aB6c7UUMrPo&t=1962s 와 그래 핀 문서이 유튜브에서보고
내가 물건을 설치했지만 그때 그것을 얻을 수 없습니다, 내가 돌연변이 쿼리를 실행할 때 오류가 발생했습니다.
나는 이와 같은 모델을 가지고 있습니다.
class Product(models.Model):
sku = models.CharField(max_length=13, help_text="Enter Product Stock Keeping Unit", null=True, blank=True)
barcode = models.CharField(max_length=13, help_text="Enter Product Barcode (ISBN, UPC ...)", null=True, blank=True)
title = models.CharField(max_length=200, help_text="Enter Product Title", null=True, blank=True)
description = models.TextField(help_text="Enter Product Description", null=True, blank=True)
unitCost = models.FloatField(help_text="Enter Product Unit Cost", null=True, blank=True)
unit = models.CharField(max_length=10, help_text="Enter Product Unit ", null=True, blank=True)
quantity = models.FloatField(help_text="Enter Product Quantity", null=True, blank=True)
minQuantity = models.FloatField(help_text="Enter Product Min Quantity", null=True, blank=True)
family = models.ForeignKey('Family', null=True, blank=True)
location = models.ForeignKey('Location', null=True, blank=True)
def __str__(self):
return self.title
내 제품이있다는 schema
글로벌 스키마가 쿼리를 이용해 주셔서 등이
class Mutation(ProductMutation,
graphene.ObjectType):
pass
class Query(FamilyQuery,
LocationQuery,
ProductQuery,
TransactionQuery,
graphene.ObjectType):
# This class extends all abstract apps level Queries and graphene.ObjectType
pass
allGraphQLSchema = graphene.Schema(query=Query, mutation=Mutation)
과 같은
class ProductType(DjangoObjectType):
class Meta:
model = Product
filter_fields = {'description': ['icontains']}
interfaces = (graphene.relay.Node,)
class CreateProduct(graphene.Mutation):
class Argument:
barcode = graphene.String()
# form_errors = graphene.String()
product = graphene.Field(lambda: ProductType)
def mutate(self, info, barcode):
product = Product(barcode=barcode)
return CreateProduct(product=product)
class ProductMutation(graphene.AbstractType):
create_product = CreateProduct.Field()
class ProductQuery(object):
product = relay.Node.Field(ProductType)
all_products = DjangoFilterConnectionField(ProductType)
def resolve_all_products(self, info, **kwargs):
return Product.objects.all()
...이 내 쿼리입니다
mutation ProductMutation {
createProduct(barcode:"abc"){
product {
id, unit, description
}
}
}
오류가 발생했습니다. ret urned
{
"errors": [
{
"message": "Unknown argument \"barcode\" on field \"createProduct\" of type \"Mutation\".",
"locations": [
{
"column": 17,
"line": 2
}
]
}
]
}
누군가 내가 시도하고해야하는 것에 대해 손을 들어 줄 수 있습니까? 어떤 도움