Skip to content

Instantly share code, notes, and snippets.

@clayallsopp
Created April 10, 2016 03:26
Show Gist options
  • Save clayallsopp/9c9175585a5f21904eb73a5213d995e3 to your computer and use it in GitHub Desktop.
Save clayallsopp/9c9175585a5f21904eb73a5213d995e3 to your computer and use it in GitHub Desktop.
const schema = new GraphQLSchema({
query: new GraphQLObjectType({
name: 'RootQueryType',
fields: {
search: {
type: new GraphQLList(SearchableType),
args: {
text: { type : new GraphQLNonNull(GraphQLString) }
},
resolve(root, args) {
const text = args.text;
return DATA.filter((d) => {
const searchableProperty = d.username || d.director || d.author;
return searchableProperty.indexOf(text) !== -1;
});
}
}
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment