-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
{}
evaluating to true is confusing
#704
Comments
Changing the behaviour of
|
How about adding a parameter to delete mutations that specifies the behaviour of |
There seems to be a few things going on together here. Calling a bulk delete with If we’re using objects to encode sets of filters, I don’t see a way around this, keeping the API as it is. The onus seems to be on the user to sanitize the inputs. If the alternative is changing the API, I definitely don’t think the solution is to change the meaning of
|
@paf31 That is a perfect summary! The best approach would be to make it harder for In a brief discussion with @0x777 and @rikinsk the proposed next step is to work on preventing the automatic collapsing of The case where users don't sanitize their input and inadvertently create a 👉 To fix: Disable collapsing of null into {} inside the Hasura BoolExp. @0x777 If you can put together the RFC for this, then we can get started! |
That case sounds like a real bug to me though. Passing |
I propose that we fix this as part of #4111. This would be a breaking change, though as has already been discussed, it seems just as likely that any situations where it comes up are bugs, not intended uses. I believe the potential for harm is significant enough that we should make the change, but if we receive reports of breakage during beta, we could add a temporary flag to re-enable the old behavior. Our current solution in #4111 is more sophisticated than what has been described in this thread so far, and I believe it addresses the mentioned concerns in a neat way. Here’s the overview:
This is intensely strange from the perspective of the GraphQL type system, since the type of the This behavior is explicitly permitted by the GraphQL specification. From the section on Input Objects:
Emphasis mine. Again, this is completely bizarre from the point of view of the GraphQL type system, but it is completely logical from the point of view of the user! The user does not think of This neatly solves the common problem where a variable accidentally ends up |
A breaking change from "probably behavior you didn't intend" to "refuse to do sketchy thing; explain situation to user" seems safe to me! |
This sounds great and certainly fits with how I'd be making the API calls in the .Net world. It would allow me to avoid writing code for generic checks to make sure no parameters are null or checking every one individually. |
The behaviour as decribed in #704 (comment) is now released in v1.3.4-beta.1 |
That kind of change in a minor version update seems dangerous to me. I think quite a few people will mindlessly upgrade those |
I've come across this issue in a situation where the current behavior or Now, the tricky part is that the value in the query itself can be null, so today I can write my query like this if I want to get all rows where any of the following are true:
As I understand the change in 1.3.4-beta.1 as described by #704 (comment), I will no longer be able to do this without writing two separate queries:
So firstly, making such a change in a minor version seems to be breaking the semver rules, as it breaks my current query above. That being said, given it fails fast instead of just returning different results, I can live with this. More importantly, am I missing some way I can write my query so that it will work with 1.3.4-beta.2, without having to write two separate queries? |
@pat154 In this case using operation allowlist quite useless. What we can do? |
It doesn't work for this query: query {
users(
where: {
nick_name: {
_ilike: null
}
}
) {
id
}
}
Also doesn't work for this: query {
users(
where: {
nick_name: null
}
) {
id
}
}
|
Every time I see breaking changes like this, which break ever more or less big project I think nobody from Hasura Team uses their product in their own projects. Maybe it is ok for a regular "Todo list" (lol)... IDK. |
In cfab5fc , we have added Note that queries which do not use operators (but use the undocumented shorthand of directly using the column) are still not supported under this flag. e.g. the following will not work even with the flag.
Again, it might be worthwhile to examine such queries because something like:
will return ALL users (i.e. the whole boolean expression resolves to true) and may not be expected. |
@tirumaraiselvan I would like to know if this flag is temporary or not. Just to know whether I have to modify all my queries soon. |
@kasugaicrow This flag will be supported in 2.0 but note that it is limited to PG source and its operators (for backwards compatibility). It is not supported for other sources like MSSQL, BiqQuery, etc. Hence, it is ideal if queries can be refactored to NOT rely on this flag. |
In the past I did things like:
By setting Writing different queries is so overkill. May we at least differentiate between |
@tirumaraiselvan Currently I think there's no clear, documented migration path to the new behaviour. How are we supposed to write optional filters in query now?
My impression is that this is very opinionated change that limits the capabilities of GraphQL - I understand that it might be painful for some to run |
With this change we can't even do |
If I understood it right, there is basically no way to do conditional _or entries depending on the input without exposing the entire bool_exp input? This is a bit frustrating because we use the Allow List, which means that allowing any arbitrary _or queries defeat the purpose of having an Allow List. |
How do we truncate a table now? |
What about performance implications? According to this article: https://hasura.io/blog/fast-graphql-execution-with-query-caching-prepared-statements/ , hasura maintaince an LRU cache of queries to avoid ast parsing. However it states:
Does it mean that when using |
I suppose the only way to achieve optional filters is to move ALL the |
We can use Nullish coalescing (??) to make sure the request contains
|
This is a no-op refactor of IR related types. Introducing a new concrete `IR` enum with `Mutation` and `Query` variants, where each contains a map of root fields. V3_GIT_ORIGIN_REV_ID: 76a197f5cf1efb34a8493c2b3356bea2bc2feb3c
{}
evaluating totrue
especially withwhere
is confusing. We had cases which a frontend bug caused one variable to be undefined and the query was sent withwhere: {}
instead ofwhere: {key:value}
and the entire table got cleared (acepsc).#701 is also due to
where: {}
matching all the rows.We need a special construct to match all the cases (that evaluates to true). An empty
{}
should mean nothing so that we can avoid accidental wiping out of the entire table usingwhere: {}
. This is bound to happen with frontend languages like JS and we should be a little forgiving there as it is our primary target.The text was updated successfully, but these errors were encountered: