question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

DjangoConnectionField and DjangoFilterConnectionField does not support NonNull connections

See original GitHub issue

Connections fields shouldn’t be nullable. I’m generating client side types through graphql introspection and have to do additional existence checking for connections. DjangoConnectionField and DjangoFilterConnectionField should default to creating NonNull connections

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
androanecommented, May 5, 2020

I think this should be opened. Solution not working starting from version 2

2reactions
maarcingebalacommented, Jan 4, 2019

I’ve created a custom connection class just for that purpose and use it successfully across the entire project. We use Apollo’s codegen + Typescript in our client apps and with these connections we have much cleaner types:

class NonNullConnection(Connection):

    class Meta:
        abstract = True

    @classmethod
    def __init_subclass_with_meta__(cls, node=None, name=None, **options):
        super().__init_subclass_with_meta__(node=node, name=name, **options)

        # Override the original EdgeBase type to make to `node` field required.
        class EdgeBase:
            node = Field(
                cls._meta.node, description='The item at the end of the edge',
                required=True)
            cursor = String(
                required=True, description='A cursor for use in pagination')

        # Create the edge type using the new EdgeBase.
        edge_name = cls.Edge._meta.name
        edge_bases = (EdgeBase, ObjectType,)
        edge = type(edge_name, edge_bases, {})
        cls.Edge = edge

        # Override the `edges` field to make it non-null list
        # of non-null edges.
        cls._meta.fields['edges'] = Field(NonNull(List(NonNull(cls.Edge))))
Read more comments on GitHub >

github_iconTop Results From Across the Web

django - The type * doesn't have a connection - Stack Overflow
When I create a DjangoObjectType and pass this to DjangoFilterConnectionField in my Query, I get an AssertionError that The type {my ...
Read more >
graphene-django Changelog - PyUp.io
This release uses Graphene v3 which drops support for Python 2 and uses the v3 version of graphql-core. See https://github.com/graphql-python/graphene/issues/ ...
Read more >
Python convert list - ProgramCreek.com
This page shows Python code examples for convert list.
Read more >
graphene: Versions - Openbase
Interfaces extending interfaces is now supported! ... Allow relay connection node to be wrapped in a NonNull type abff3d75a39bc8f2d1fdb48aafa1866cf47dfff6 ...
Read more >
graphql-python/graphene-django v3.0.0 on GitHub
... fix(converter): wrap field with NonNull if it is required by @helloqiu in #545; Warn if fields or exclude are not defined on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found