graphql-compose-examples icon indicating copy to clipboard operation
graphql-compose-examples copied to clipboard

No example with more complex queries is present

Open ziedHamdi opened this issue 7 years ago • 2 comments
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
  }
}
     

ziedHamdi avatar Jul 04 '18 13:07 ziedHamdi

https://github.com/graphql-compose/graphql-compose/issues/3#issuecomment-245507130

st0ffern avatar Jul 05 '18 11:07 st0ffern

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
  }
}

nodkz avatar Jul 10 '18 12:07 nodkz