私はチュートリアルをオンラインで行っており、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 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()
グローバルスキーマは、クエリを試すために、この
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)
のように見えます私は私のプロダクトのためにこれを持っている...これは
mutation ProductMutation {
createProduct(barcode:"abc"){
product {
id, unit, description
}
}
}
私のクエリです
エラーリターンurned
{
"errors": [
{
"message": "Unknown argument \"barcode\" on field \"createProduct\" of type \"Mutation\".",
"locations": [
{
"column": 17,
"line": 2
}
]
}
]
}
私が試してやるべきことを誰かに教えてもらえますか?
ご協力いただきありがとうございます。