art1415926535 / graphene-sqlalchemy-filter

Filters for Graphene SQLAlchemy integration
https://pypi.org/project/graphene-sqlalchemy-filter/
MIT License
118 stars 34 forks source link

AND / OR doesn't work with repeating clauses #36

Closed davidcim closed 3 years ago

davidcim commented 3 years ago

Something like this doesn't work as you would expect, only the last and clause is taken:

{
  cuentas(first: 10, filters: {and: {cuentaIlike: "%co%" cuentaIlike: "%pa%"}}) {
    edges {
      node {
        idCuenta
        cuenta
      }
    }
  }
}

You can get it to work with this hack:

{
  cuentas(first: 10, filters: {and: {cuentaIlike: "%co%" and: {cuentaIlike: "%pa%"}}}) {
    edges {
      node {
        idCuenta
        cuenta
      }
    }
  }
}
art1415926535 commented 3 years ago

Have a look at the documentation in graphiql. and is a list of filters. e.g.: image

Correct query:

{
  cuentas(first: 10, filters: {and: [{cuentaIlike: "%co%"}, {cuentaIlike: "%pa%"}]}) {
    edges {
      node {
        idCuenta
        cuenta
      }
    }
  }
}
davidcim commented 3 years ago

Thank you, I missed that.