Closed a-zog closed 4 years ago
What version of Sequelize? But in general i would recommend not using anapproach like this
Version 4.38.1 What approach would you recommend?
@a-zog we'll have to request more detail or test with latest version for this issue, we have been using sequelize ops in the where clause and haven't found an issue, are you sure you wanted to query name
and not fname
here ?
@mickhansen please give us a few words on a better approach, I'm also curious about that, Thanks.
To me, exposing something like where
taking an arbitrary sql-ish statement seems non-idiomatic with GraphQL.
I'd expose expressive arguments that does what you need and then map those arguments to where statements.
It's on my to do list to remove the built-in where
support, and someone offer it as a plugin instead.
What if we want to do a special filter based on permissions, where we would need a sequleize or operator. Not sure why sequelize-graphql doesn't work with sequelize operators. It makes wonder about the future of this plugin.
@brianschardt define the filter as an argument and use $or based on it being present, or am i misunderstanding something?
As i mentioned i don't believe this to be idiomatic or good graphql schema design, but anyone is free to provide a plugin that offers this functionality - as the sole maintainer i don't want to spend resources maintaining it however.
@brianschardt you can use the operators without the $.
where: {
or: [{id: 1}, {name: "foo"}]
}
But in general, I side with @mickhansen, it's better to add this behavior server side and use a flag to enable/disable it. Even more if it's related to security/permissions! For that, inject a where inside the "findOptions" parameter using the "before" hook.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I wasn't able to use queries having Sequelize Operators in where clauses.
This is a quick preview of the test:
Any idea about how to solve the issue?