Skip to content

Supporting multiple Union types in one schema #84

Closed

Description

@filipncs

Currently having two different Union types in a single schema seems to be impossible if both have to be represented as java.lang.Object in the resolver return signature (which I imagine is a pretty common case for unions).

I've created a PR to illustrate this issue, extending the end-to-end schema test with a second union, causing it to fail: #83

Am I missing something stupid here? If not, there seem to be some fairly straightforward ways to fix this, but I don't know which way is better.

One simple solution would be to leave unions out of the type<->class bimap altogether, as you would generally only need a typeresolver for the types within the union, not the union itself (except in case of nested unions).

Thoughts?

Activity

  1. filipncs commented on Oct 19, 2017

    @filipncs
    ContributorAuthor

    I added another commit to the PR, with one possible way of resolving the issue, by handling unions and their possible types separately. This also supports nested unions.

    Apologies for what I imagine is clumsy code. I'm new to Kotlin.

    The explicit test for handling of nested unions is on the flimsy side, due to the fact that the test data is mutated by other tests. I left it as-is for now, but this might also be worth cleaning up.

  2. apottere commented on Nov 23, 2017

    @apottere
    Collaborator

    Thanks for the PR! I'll be releasing this soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions