Skip to content

Fix passing required=True to DjangoConnectionField #609

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

Merged
merged 2 commits into from
May 6, 2019

Conversation

alexkirsz
Copy link
Contributor

Passing required=True to an instance of DjangoConnectionField currently raises the following exception:

  ...
  File "/env/lib/python3.6/site-packages/graphql/type/typemap.py", line 106, in reducer
    field_map = type.fields
  File "/env/lib/python3.6/site-packages/graphql/pyutils/cached_property.py", line 22, in __get__
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "/env/lib/python3.6/site-packages/graphql/type/definition.py", line 221, in fields
    return define_field_map(self, self._fields)
  File "/env/lib/python3.6/site-packages/graphql/type/definition.py", line 235, in define_field_map
    field_map = field_map()
  File "/env/lib/python3.6/site-packages/graphene/types/typemap.py", line 274, in construct_fields_for_type
    map = self.reducer(map, field.type)
  File "/env/lib/python3.6/site-packages/graphene-django/graphene_django/fields.py", line 61, in type
    _type, DjangoObjectType
TypeError: issubclass() arg 1 must be a class

The reason for the exception is that DjangoConnectionField does not expect its type to be wrapped in a NonNull instance. This PR ensures that it handles that case properly.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 94.071% when pulling 8beadc7 on acu:fix-connection-field-required into ea2cd98 on graphql-python:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 94.071% when pulling 8beadc7 on acu:fix-connection-field-required into ea2cd98 on graphql-python:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 94.071% when pulling 8beadc7 on acu:fix-connection-field-required into ea2cd98 on graphql-python:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.3%) to 94.071% when pulling 8beadc7 on acu:fix-connection-field-required into ea2cd98 on graphql-python:master.

@coveralls
Copy link

coveralls commented Mar 30, 2019

Coverage Status

Coverage decreased (-0.4%) to 93.934% when pulling b49d315 on acu:fix-connection-field-required into ea2cd98 on graphql-python:master.

root,
info,
**args
cls,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 spaces should be 4!

@alexkirsz
Copy link
Contributor Author

@phalt Done!

Copy link
Contributor

@phalt phalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me - @alexkirsz this isn't a breaking change is it?

@alexkirsz
Copy link
Contributor Author

@phalt The previous behaviour was to raise an exception, so I don't believe there's any way in which this could break non-already broken code :)

@phalt
Copy link
Contributor

phalt commented May 2, 2019

@alexkirsz approval from me then!

@phalt phalt merged commit 0d178b3 into graphql-python:master May 6, 2019
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

Successfully merging this pull request may close these issues.

4 participants