-
-
Notifications
You must be signed in to change notification settings - Fork 250
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
query with filter generates wrong query string #1272
Comments
Why is the generated query invalid? Without knowing the schema, I don't see what's wrong with it. Noted on the documentation of |
Hi @ghostdogpr! The generated query is syntactically correct, but we just get an empty result. query NotBrokenAnymore {
products(where: {public_id: {_eq: "8001"}}) {
id
name
image {
url
height
width
description
}
slug
public_id
}
} I enabled query logging on hasura and executed both queries. See this gist with the hasura log (it's in json format) and the extracted and formatted sql queries. ((NOT ('true')) AND (('false') AND (("public"."products"."public_id") = ((8001)::text)))) Do you have an idea, what might have caused that |
I think this is related to how Hasura interpret the null parameters, it must have a different meaning from the absence of parameters. So what you observed is expected, what you probably want is just to get rid of the null parameters. There are 2 ways for that: one way is passing implicit val encoderWithoutNull: ArgEncoder[CharacterInput] = CharacterInput.encoder.dropNullValues
val query = Query.addCharacter(CharacterInput("name", None, Nil))(Character.name) |
Ah, I see. Thanks for the clarification and the example! |
Hi!
We wanted to create a query where we filter a table by one column.
This is our scala code and the generated query is below.
The query doesn't return any results, even though it should. We found out that we can use the property
dropNullInputValues
on thetoRequest
function of theSelectionBuilder
. If we set this property to true, we get a valid query and also the expected result.We had two issues actually - for one it isn't well documented (and we didn't find any tests/examples) and on the other hand leaving it to false (the default) the generated query is wrong.
Would you mind showing us how to use the filter properly?
The text was updated successfully, but these errors were encountered: