graphene-django icon indicating copy to clipboard operation
graphene-django copied to clipboard

Nullable ArrayField converted to not nullable GraphQL Type

Open Akkarine opened this issue 4 years ago • 1 comments

  • What is the current behavior? Аfter #545 for django.db.models.ArrayField with null=True we getting not nullable GraphQL Type.

  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem via a github repo, https://repl.it or similar (you can use this template as a starting point: https://repl.it/@jkimbo/Graphene-Django-Example). All same as in #536, but define ArrayField as nullable in model:

class Example(models.Model):
    simple_array = ArrayField(models.CharField(max_length=255), blank=True, null=True)
  • What is the expected behavior? We can have null values for this field.

  • What is the motivation / use case for changing the behavior?

  • Please tell us about your environment:

    • Version: graphene-django 2.15
    • Platform: Django 3.1.6
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)

We used older version before and all was fine (that's why I blame #545)

My case:

image

Type is defined simply through Meta:

class SpecificationType(DjangoObjectType):

    class Meta:
        model = Specification

Akkarine avatar Feb 16 '21 19:02 Akkarine

A little thought brought a workaround (so not sure, if it is still a bug). If you also provide null=True for base_field, all works fine:

class Example(models.Model):
    simple_array = ArrayField(models.CharField(max_length=255, blank=True, null=True), blank=True, null=True)

Akkarine avatar Feb 16 '21 19:02 Akkarine