Created
April 10, 2016 03:26
-
-
Save clayallsopp/9c9175585a5f21904eb73a5213d995e3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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