Skip to content

Instantly share code, notes, and snippets.

@clayallsopp
Last active April 10, 2016 03:35
Show Gist options
  • Save clayallsopp/5bb3718745864a6d3b54b0eec028f853 to your computer and use it in GitHub Desktop.
Save clayallsopp/5bb3718745864a6d3b54b0eec028f853 to your computer and use it in GitHub Desktop.
const resolveType = (data) => {
if (data.username) {
return UserType;
}
if (data.director) {
return MovieType;
}
if (data.author) {
return BookType;
}
};
const SearchableType = new GraphQLUnionType({
name: 'SearchableType',
types: [ UserType, MovieType, BookType ],
resolveType: resolveType
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment