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

Expose AND and OR logical operators in GraphQL query filters #579

Closed
fordN opened this issue Nov 16, 2018 · 4 comments
Closed

Expose AND and OR logical operators in GraphQL query filters #579

fordN opened this issue Nov 16, 2018 · 4 comments
Assignees
Labels
area/graphql enhancement New feature or request

Comments

@fordN
Copy link
Contributor

fordN commented Nov 16, 2018

Where filters should allow AND and OR logical operators to combine and nest conditions in the GraphQL queries.

@Jannis
Copy link
Contributor

Jannis commented Nov 16, 2021

The way this was initially intended to look like was:

{
  users(where:
    # implicit AND at the top level
    {
      name_startsWith: "A",
      OR: {
        name_endsWith: "c",
        name_endsWith: "d",
        AND: {
          name_contains: "o",
          name_contains: "i",
        }
      }
    }
  ) {
    ...
  }
}

The above would return all users whose names start with "A" and either

  • ends with "c"
  • ends with "d"
  • contains an "o" and an "i"

Open questions:

  • Is this a good design? (How do others do it?)
  • Do we want to enforce a limit on the depth? (1-2-3 levels?)

@montanaflynn
Copy link

montanaflynn commented Mar 4, 2022

I'd also like this, especially because I cannot match null using *_in:

query  {
        erc721Tokens(
            orderBy: identifier,
            orderDirection: asc,
            where: {hat_in:["Bucket", "Cowboy"]}
        ) {
            identifier
            owner {
                id
            }
        }
}

What I really need is matching where Bucket || Cowboy || null.

I think this would be intuitive, especially since both hat_in:["Bucket", "Cowboy"] and hat:null work as expected when ran individually:

query  {
        erc721Tokens(
            orderBy: identifier,
            orderDirection: asc,
            where: {hat_in:["Bucket", "Cowboy"] OR hat:null}
        ) {
            identifier
            owner {
                id
            }
        }
}

@saihaj saihaj moved this from In Progress to Todo in GraphQL API Apr 19, 2022
@compojoom
Copy link

Is this supposed to only work on the same field or can we combine multiple fields like:

where: {hat_in: ["bucket", "Cowboy"] OR shoe: "46"}

@saihaj saihaj moved this from Todo to In Progress in GraphQL API Sep 7, 2022
@saihaj saihaj moved this from In Progress to In review in GraphQL API Sep 14, 2022
@saihaj
Copy link
Member

saihaj commented Nov 10, 2022

#4080

@saihaj saihaj closed this as completed Nov 10, 2022
Repository owner moved this from In review to Done in GraphQL API Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/graphql enhancement New feature or request
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

8 participants