Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse foreign_key Input problem #164

Open
miliakhaled opened this issue Dec 13, 2020 · 0 comments
Open

Reverse foreign_key Input problem #164

miliakhaled opened this issue Dec 13, 2020 · 0 comments

Comments

@miliakhaled
Copy link

miliakhaled commented Dec 13, 2020

Hello,
I have the following code

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'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant