graphql-python / graphql-python/graphene
Bug integrating with DRF
- Ngôn ngữ chính
- Python
- Star
- 8.2k
- Fork
- 818
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
I followed the steps in https://graphene-django-murali.readthedocs.io/en/latest/rest-framework.html
```
class Produto(models.Model):
nome = models.CharField(max_length=50, unique=True)
tamanho = models.IntegerField(null=True, blank=True)
preco = models.DecimalField(max_digits=8, decimal_places=2)
quantidade = models.IntegerField()
def __str__(self):
return self.nome
class Meta:
verbose_name = "Produto"
verbose_name_plural = "Produtos"
class ProdutoType(DjangoObjectType):
class Meta:
model = Produto
class ProdutoSerializer(serializers.ModelSerializer):
class Meta:
model = Produto
fields = ("id", "nome", "tamanho", "preco", "quantidade")
class QueryDefinition(graphene.ObjectType):
all_produtos = graphene.List(ProdutoType)
def resolve_all_produtos(self, info, **kwargs):
return Produto.objects.all()
class ProdutoSerializerMutation(SerializerMutation):
class Meta:
serializer_class = ProdutoSerializer
class Mutations(graphene.ObjectType):
create_or_update_produto = ProdutoSerializerMutation.Field()
schema = graphene.Schema(mutation=Mutations, query=QueryDefinition)
```
The project runs but when i'm testing i can create and list objects normally but in update it not accept id value
```
mutation {
createOrUpdateProduto(input:{id: 6, nome: "a", tamanho: 1, preco: 0, quantidade:0}){
id
nome
}
}
{
"errors": [
{
"message": "Argument \"input\" has invalid value {id: 6, nome: \"a\", tamanho: 1, preco: 0, quantidade: 0}.\nIn field \"id\": Unknown field.",
"locations": [
{
"line": 2,
"column": 31
}
]
}
]
}
```
If i put only update in model_operations inside ProdutoSerializerMutation it complains that id is unknown field but if i take if out it complains that it should have an id
My versions:
Django==3.1.4
djangorestframework==3.12.2
graphene==2.1.8
graphene-django==2.13.0
graphql-core==2.3.2
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu với hướng dẫn tích hợp rest-framework.html được liên kết trong issue và tái hiện các mutation create và update bằng cấu hình ProdutoSerializerMutation được minh họa. Theo dõi cách model_operations và input id được xử lý, sau đó xác minh rằng một update chấp nhận mã định danh mà không làm cho luồng create không hợp lệ.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- graphql, python
- Lĩnh vực
- api, backend
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100