Skip to content

Allow the Union type to be used in relay connections - #367

Closed
tangerilli wants to merge 4 commits into
graphql-python:masterfrom
tangerilli:union_connections
Closed

tangerilli wants to merge 4 commits into
graphql-python:masterfrom
tangerilli:union_connections

Conversation

@tangerilli

Copy link
Copy Markdown

The union node needs a Connection type for things to work, so I create one for each type of union in the union meta class. Maybe there's a better way to handle it?

@coveralls

coveralls commented Nov 15, 2016 •

Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.2%) to 96.0% when pulling c4442b6 on tangerilli:union_connections into 3c99302 on graphql-python:master.

@syrusakbary

Copy link
Copy Markdown
Member

Hi @tangerilli,

The way Connections work will be changed by #347 (removing the need of an ObjectType for have a Connection on it).

You can still make Connection work with Union, doing something like:

class MyUnion(Union):
    class Meta:
        types = (MyObjectType1, MyObjectType2)

class MyUnionConnection(Connection):
    class Meta:
        node = MyUnion

class Query(ObjectType):
    objects = ConnectionField(MyUnionConnection)

    def resolve_objects(self, args, context, info):
        return [MyObjectType1(), MyObjectType2()]

@tangerilli

Copy link
Copy Markdown
Author

@syrusakbary thanks, that worked!

@tangerilli tangerilli closed this Nov 16, 2016
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.

3 participants