mickhansen / graphql-sequelize

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

Literals in Relay createConnectionResolver({...}) where param stopped working #668

Closed intellix closed 5 years ago

intellix commented 5 years ago

Sequelize 4.44

Got something like this:

relay.createConnectionResolver({
  target: () => BoxItem,
  ignoreArgs: { ...connectionArgs, orderBy: true },
  where: () => {
    return {
      boxId: {
        [Op.eq]: sequelize.literal(`(SELECT "id" FROM "Box" WHERE "slug" = 'abc' and "marketId" = 1)`),
      },
    };
  },
});

Caused by this commit with replaceWhereOperators: https://github.com/mickhansen/graphql-sequelize/commit/3cb923f0799092df15cccd033363be7ef7730e97

When stepping through the debugger it seems like the type is lost:

Before:

Screenshot 2019-06-07 19 58 28

After:

Screenshot 2019-06-07 20 00 00
intellix commented 5 years ago

I'm not sure if this should work really. I can shove all of my logic into the before hook instead the where param. I don't know why I put it there in the first place.

mickhansen commented 5 years ago

Since we still support where it probably should work, not exactly sure how it broke, perhaps @Azerothian can lend some assistance.

mickhansen commented 5 years ago

I personally only use before, i just find it easier when you have args that might influence eachother etc.

intellix commented 5 years ago

Thanks :) I've moved all logic from where to before. Not sure why I used it before

mickhansen commented 5 years ago

where was what i thought would be a clever idea, but in practice it sees little effective use.