Class OurLivraison(models.Model):
......
class Mouvement(models.Model):
livraison = livraison = models.ForeignKey("livraison.Livraison", on_delete=models.CASCADE)
class OurLivraisonMutation(CustomDjangoSerializerMutation):
class Meta:
serializer_class = serializers.OurLivraisonSerializer
nested_fields = {"mouvements": MouvementSerializer}
class MouvementSerializer(serializers.ModelSerializer):
class Meta:
model = models.Mouvement
# exclude = ('livraison',)
# fields = '__all__'
exclude = ('livraison',)
The problem is when generating types for inputs, especially for nested fields, you have to define the the reverse relation.
mutation {
create_ourlivraison(input:
{
mouvements: [
{
wilaya:12,
operation_type:CHARGEMENT
# livraison:"1" This field should not berequired, although the create function doesn't take in consideration
}
],
}){
ok
}
}
So as you can see, The input object type force me to define the reverse foreign key 'livraison', although the result of the creation is correct, whatever value I put in 'livraison'.
Hello, I have the following code
The problem is when generating types for inputs, especially for nested fields, you have to define the the reverse relation.
So as you can see, The input object type force me to define the reverse foreign key 'livraison', although the result of the creation is correct, whatever value I put in 'livraison'.