Skip to content

Strapi filter: the "or" works as "and" in graphql #14302

@ahmadjoya

Description

@ahmadjoya

Bug report

  • Node.js version: 16.15.1
  • NPM version: 8.11.0
  • Strapi version: 4.3.6
  • Database: postgreSQL
  • Operating system: Windows

Strapi filter: "or" works as "and" in graphql

hello community!
I am troubled while wanted to use complex filter using "or" for two fields.
here firstly I wanted filter by slug and setting an or operator that if the first filter is not working, than the second operator which is filter by itSlug should run.

Screenshots

this single filter is working

image

this complex query is not working

image

Code snippets

query category($locale: I18NLocaleCode, $slug: String) {
    categories(locale: $locale, filters: {slug: {eq: $slug}, or: [{itSlug: {eq: $slug}}]} ) {
      data {
        id
        attributes {
          categoryName
          slug
          description
          locale
        }
      }
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions