Skip to content
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

Interface support #6

Closed
andreas opened this issue Nov 7, 2016 · 4 comments · Fixed by #70
Closed

Interface support #6

andreas opened this issue Nov 7, 2016 · 4 comments · Fixed by #70

Comments

@andreas
Copy link
Owner

andreas commented Nov 7, 2016

See:

@sgrove
Copy link

sgrove commented Jul 29, 2017

We're coming against a use case where we need interfaces as well, any thoughts on how to support this?

@andreas
Copy link
Owner Author

andreas commented Jul 29, 2017

I have some ideas, but it's not straight forward. Could unions be used to solve the use case? I think they will be easier to implement.

@sgrove
Copy link

sgrove commented Jul 31, 2017

From the spec and https://medium.com/the-graphqlhub/graphql-tour-interfaces-and-unions-7dd5be35de0d, it looks like it. I gave a bit of an example in #33 (comment), where we might have a number of Urls returned in a resolver, but as different types (VideoUrl, CommentUrl, PlainUrl, DescriptionUrl), and want to be able to traverse differently depending on the type:

{
  urls {
    __typename
    ... on VideoUrl {
      url {
        expandedText
        displayedText
        description
      }
      video {
        title
        user {
          email
        }
      }
    }
    ... on CommentUrl {
      url {
        expandedText
        displayedText
        description
      }
      comment {
        body
        created_at
        user {
          email
        }
      }
    }
    ... on PlainUrl {
      url {
        expandedText
        displayedText
        description
      }
    }
  }
}

Looks like the ... on <__typename works already, but I'm not sure how to return different types from a resolver.

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

Successfully merging a pull request may close this issue.

3 participants