graphql-compose-examples
graphql-compose-examples copied to clipboard
No example with more complex queries is present
trafficstars
Hi All,
I've asked the question on SO, basically I'd like to have an example of a LIKE query : which silently gives no results (does not throw any error and doesn't answer correctly) knowing that in mongoose, filter: { name: "/MICH/i" } will return results where name is LIKE "mich" in a case insensitive search:
{
userMany(filter: { name: "/MICH/i" }, limit: 5, sort: _ID_ASC) {
name
languages {
language
skill
}
contacts {
email
}
gender
age
}
}
https://github.com/graphql-compose/graphql-compose/issues/3#issuecomment-245507130
Or even better read this https://github.com/graphql-compose/graphql-compose/issues/22
UserTC
.getResolver('findMany')
.addFilterArg({
name: 'nameRegexp',
type: 'String', // also can be 'Int Float Boolean ID String! [String] AnyNamedType'
description: 'Search by regExp',
query: (rawQuery, value, resolveParams) => {
rawQuery.name = new RegExp(value, 'i');
},
})
Then you may write such query:
{
userMany(filter: { nameRegexp: "MICH" }, limit: 5, sort: _ID_ASC) {
name
languages {
language
skill
}
contacts {
email
}
gender
age
}
}