mickhansen / graphql-sequelize

GraphQL & Relay for MySQL & Postgres via Sequelize
MIT License
1.9k stars 172 forks source link

Where Invalid value like #614

Closed pbrink231 closed 6 years ago

pbrink231 commented 6 years ago

I am pulled to the latest version as of today which had a Sequelize V4 pull 8 days ago.

I am using Sequelize version 4

I can run this query and be fine but the other ones do not work and return "Invalid value { '$iLike': '%dfs%' }"

        Op = Sequelize.Op
        before: (findOptions, args) => {
          if (args.query) {
            findOptions.where = {
        name: { [Op.iLike]: '%' + args.query + '%' } // -> Works fine
        // name: { $iLike: '%' + args.query + '%' } // -> Does not work
                // name: { iLike: '%' + args.query + '%' }  // -> Does not work
            }
          }
          return findOptions;
        }

I was trying to understand the new scrubbing method but dont fully understand what is happening yet but wanted to bring this up.

mickhansen commented 6 years ago

AFAIR the old operators are removed in Sequelize v4? You should verify if the query works in Sequelize standalone.

pbrink231 commented 6 years ago

Yes from the docs the old $ are removed. I saw this file which is suppose to convert them so they will work with v3 or v4 but doesn't seem to be working. https://github.com/mickhansen/graphql-sequelize/blob/master/src/sequelizeOps.js

I confirm that this setup using Op.iLike does work directly with sequelize directly.

mickhansen commented 6 years ago

@pbrink231 That file is not used for compability, it's used for if you use the where argument that this library can proide.

pbrink231 commented 6 years ago

O I understand. It doesnt check all wheres. just if a where is sent into graphql as an argument which I could use in this case instead?

mickhansen commented 6 years ago

You could, i wouldn't recommend it.