Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No example with more complex queries is present #29

Open
ziedHamdi opened this issue Jul 4, 2018 · 2 comments
Open

No example with more complex queries is present #29

ziedHamdi opened this issue Jul 4, 2018 · 2 comments

Comments

@ziedHamdi
Copy link

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
  }
}
     
@st0ffern
Copy link

st0ffern commented Jul 5, 2018

@nodkz
Copy link
Member

nodkz commented Jul 10, 2018

Or even better read this graphql-compose/graphql-compose#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
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants