graphql / graphql/graphql-spec

Algebraic interface types

Open
#48 9 comments 0 reactions 0 assignees View on GitHub
👻 Needs Champion 💭 Strawman (RFC 0)
Dominant language
JavaScript
Stars
14.6k
Forks
1.2k
PR merge metrics
No merged PRs in 30d

Description

As originally discussed in graphql/graphql-js#45, it would be useful to be able to declare a field type to be a combination of interfaces.

As an example use-case, let's say I have an interface

```
interface Image {
src: String
}
```

which represents an image I can display. Some images are stand-alone and I can link to them as a page, but other things share that capability (videos for instance). So I have another interface

```
interface Linkable {
url: String
}
```

Now let's say that all users have profile pictures which are linkable. I'd like to be able to declare something like this

```
type User {
profilePicture: Image + Linkable
}
```

When resolving such type, the only requirement is for the interfaces not to contain the same attributes. From there it should be possible to find the defining interface for each attribute and then the implementing type based on interface type resolution.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.