graphene-django-cud
graphene-django-cud copied to clipboard
many to many extra not working
Hi I have these models
class package(models.Model):
items = models.ManyToManyField('product.item', verbose_name=_("Items"), related_name="package_items")
class item(models.Model):
products = models.ManyToManyField('product.product', verbose_name=_("Products"), null=True, blank=True)
class product(models.Model):
options = models.ManyToManyField("product.option", verbose_name=_("Product options"), null=True, blank=True)
and this is my mutation for package
and item
class create_package(DjangoCreateMutation):
class Meta:
model = package
many_to_many_extras = {
'items': {
'add':{'type': 'CreateitemInput'}
}
}
class create_item(DjangoCreateMutation):
class Meta:
model = item
many_to_many_extras = {
'products': {
'add':{'type': 'CreateproductInput'}
}
}
class create_product(DjangoCreateMutation):
class Meta:
model = product
many_to_many_extras = {
'options': {
'add':{'type': 'CreateoptionInput'}
}
}
And when I run a mutation like this:
mutation{
createPackage(
input:{
name:"random"
description:"boring"
sideBarText:"sample"
items:[
1
]
itemsAdd:[
{
name:"bla bla bla"
displayName:"kdjhb"
products:[
"cHJvZHVjdF90eXBlOjE="
]
productsAdd:[
{
name:"product bla"
description:"double trouble"
price:"99.99"
}
]
}
]
}
){
package{
name
items{
edges{
node{
name
products{
edges{
node{
name
price
}
}
}
}
}
}
}
}
}
I only get the added product returned, why isn't the other product being added?
Is there any update on this?
Hi I have these models
class package(models.Model): items = models.ManyToManyField('product.item', verbose_name=_("Items"), related_name="package_items") class item(models.Model): products = models.ManyToManyField('product.product', verbose_name=_("Products"), null=True, blank=True) class product(models.Model): options = models.ManyToManyField("product.option", verbose_name=_("Product options"), null=True, blank=True)
and this is my mutation for
package
anditem
class create_package(DjangoCreateMutation): class Meta: model = package many_to_many_extras = { 'items': { 'add':{'type': 'CreateitemInput'} } } class create_item(DjangoCreateMutation): class Meta: model = item many_to_many_extras = { 'products': { 'add':{'type': 'CreateproductInput'} } } class create_product(DjangoCreateMutation): class Meta: model = product many_to_many_extras = { 'options': { 'add':{'type': 'CreateoptionInput'} } }
And when I run a mutation like this:
mutation{ createPackage( input:{ name:"random" description:"boring" sideBarText:"sample" items:[ 1 ] itemsAdd:[ { name:"bla bla bla" displayName:"kdjhb" products:[ "cHJvZHVjdF90eXBlOjE=" ] productsAdd:[ { name:"product bla" description:"double trouble" price:"99.99" } ] } ] } ){ package{ name items{ edges{ node{ name products{ edges{ node{ name price } } } } } } } } }
I only get the added product returned, why isn't the other product being added?
many-to-many is working on my side Please can you highlight or point out which item is added and which ones are not added?