Skip to content

Conversation

syrusakbary
Copy link
Member

@syrusakbary syrusakbary commented Nov 3, 2016

This PR improves the relay.Connection APIs in Graphene.
Is inspired on the work of @Globegitter in #288 and following #304.

Things that this PR should achieve:

  • Remove automatic .Connection creation in Nodes in pro of cleaner and more explicit code
  • Remove the graphql-relay dependency.
  • One connection type could have different resolving strategies (different cursors / In a fully list, in a iterable without an explicit length = django queryset, ...)

Related issues

#304 #180 #62

@coveralls
Copy link

coveralls commented Nov 3, 2016

Coverage Status

Coverage decreased (-0.4%) to 95.487% when pulling 42b93b5 on features/connection into adfbffb on master.

if isinstance(resolved, connection_type):
return resolved

on_resolve = partial(connection_type.connection_resolver, args=args, context=context, info=info)
if isinstance(resolved, Promise):
Copy link

@Globegitter Globegitter Nov 3, 2016

Choose a reason for hiding this comment

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

The only minor problem I have with this is that the instance check does not allow for duck-typing, which goes in line with graphql-python/graphql-core#91 and is a quite common principle in python.

@classmethod
def connection_resolver(cls, resolver, connection_type, root, args, context, info):
resolved = resolver(root, args, context, info)

on_resolve = partial(cls.resolve_connection, connection_type, args)
if isinstance(resolved, connection_type):
Copy link

@Globegitter Globegitter Nov 3, 2016

Choose a reason for hiding this comment

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

Support for duck-typing would be nice here as well but I think it would probably be far less used and more a nit-pick from my side.

@Globegitter
Copy link

Liking the direction this is heading so far :)

@coveralls
Copy link

coveralls commented Nov 4, 2016

Coverage Status

Coverage decreased (-0.4%) to 95.496% when pulling 3fa65aa on features/connection into adfbffb on master.

@coveralls
Copy link

coveralls commented Nov 4, 2016

Coverage Status

Coverage decreased (-0.4%) to 95.496% when pulling e6733d5 on features/connection into adfbffb on master.

@tsunammis
Copy link

Hello @syrusakbary
Since your commit -> 760ccc8, Is it not possible to use async resolver method for a relay.ConnectionField, isn't it ?

I get this error -> AssertionError: Resolved value from the connection field have to be iterable or instance of SectionConnection. Received "<coroutine object get_sections at 0x7f0de4b14518>"

@ajhyndman
Copy link

Hey guys. I'm wondering what the status is on this PR. It seems like some of the documented Connection APIs might be out of date?

I'm getting errors that look like this when I try to declare a property with type ConnectionField(MyNode):

16, in is_node
    if not issubclass(objecttype, ObjectType):
TypeError: issubclass() arg 1 must be a class

@syrusakbary
Copy link
Member Author

Closing in favor of #500

@ProjectCheshire ProjectCheshire deleted the features/connection branch June 2, 2019 22:48
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.

5 participants