Skip to content
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

Graphql filter "or" is not working properly #4472

Closed
DrHe1991 opened this issue Apr 19, 2020 · 5 comments
Closed

Graphql filter "or" is not working properly #4472

DrHe1991 opened this issue Apr 19, 2020 · 5 comments

Comments

@DrHe1991
Copy link

DrHe1991 commented Apr 19, 2020

Hello there,
I found that the filter "or" is not working properly in hasura at version 1.11 and lower verison.
Case1:

query MyQuery {
  recent_messages(where: {_or: {opp_id: {_eq: "ebd75875-3a18-429a-b681-25b404471886"}, user_id: {_eq: "ebd75875-3a18-429a-b681-25b404471886"}}}) {
    opp_id
    message_id
  }
}

returns

{
  "data": {
    "recent_messages": []
  }
}

But
Case2:

query MyQuery {
  recent_messages(where: {user_id: {_eq: "ebd75875-3a18-429a-b681-25b404471886"}}) {
    opp_id
    message_id
  }
}

returns

{
  "data": {
    "recent_messages": [
      {
        "opp_id": "55a07435-14a0-41af-87ab-9365025fa688",
        "message_id": "a25b9716-d780-49bd-bbe0-3aab1b919b7f"
      }
    ]
  }
}

This is not right. The "or" clause should return at least one result in Case 1, right? Did I use the clause in the wrong way? Can someone double check this? Thank you!

Chris

@DrHe1991 DrHe1991 changed the title Graphql Filter "or" is not working properly Graphql filter "or" is not working properly Apr 19, 2020
@GavinRay97
Copy link
Member

GavinRay97 commented Apr 20, 2020

Edit: or clauses need an array of object or they function like and clauses:

image

https://hasura.io/docs/1.0/graphql/manual/api-reference/graphql-api/query.html#orexp

@GavinRay97 GavinRay97 added c/console Related to console c/docs Related to docs c/server Related to server k/bug Something isn't working k/question and removed c/console Related to console c/docs Related to docs c/server Related to server k/bug Something isn't working labels Apr 20, 2020
@GavinRay97
Copy link
Member

Edited my previous comment

@DrHe1991
Copy link
Author

DrHe1991 commented Apr 21, 2020

Thanks for pointing that out. I was using the hasura "Explorer" to build the query and I thought it should give me the query I want for or logic. However, it will generate the logic like and
I still hope someone can make that easier to use.

@tirumaraiselvan
Copy link
Contributor

GraphiQL-explorer has a bug where it doesn't open an array.

We are tracking improving the usability of this here: #4488

@AliNaraghiA
Copy link

galleries(filter: {title: {eq: "rain"}}) me to o

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants