ezplatform-graphql icon indicating copy to clipboard operation
ezplatform-graphql copied to clipboard

EZP-32303: As a Developer I want GraphQL allow filtering by Subtree and IsFieldEmpty

Open ITernovtsii opened this issue 4 years ago • 6 comments

Question Answer
JIRA issue EZP-32303
Type improvement
Target eZ Platform version v3.3
BC breaks no
Doc needed yes

Currently, it's not possible to filter content by Subtree (while parent location id available). I would like to add more filters, like Subtree and IsFieldEmpty.

{
  content {
    folders(query: {
      Subtree: "/1/2/63"
      IsFieldEmpty: {
        target: "description"
        empty: false
      }
    }) {
      edges {
        node { name }
      }
    }
  }
}

Checklist:

  • [x] Provided PR description.
  • [x] Tested the solution manually.
  • [x] Provided automated test coverage.
  • [x] Ran PHP CS Fixer for new PHP code (use $ composer fix-cs).
  • [x] Asked for a review

ITernovtsii avatar Jan 22 '21 05:01 ITernovtsii

let me know if 2.2 closed for improvements and I'll rebase to master

ITernovtsii avatar Jan 22 '21 05:01 ITernovtsii

Thank you for the pull-request, @ITernovtsiy. It looks okay from a code perspective.

One note, though: there will always be limits to what can be done by manually crafting filters in graphql queries. Our answer to that is the query field, that gives you much more flexibility and keeps the content logic inside the repository. Maybe it would work for you ?

bdunogier avatar Jan 25 '21 09:01 bdunogier

Indeed, sorry, I missed that query types are available in GraphQL, thanks @bdunogier May I close this PR? or is it still something you would like to see as a basic filter?

ITernovtsii avatar Jan 25 '21 10:01 ITernovtsii

May I close this PR? or is it still something you would like to see as a basic filter?

I think they don't do any harm, we may as well merge them. Let's see what the @ezsystems/php-dev-team thinks about it :)

bdunogier avatar Jan 26 '21 10:01 bdunogier

dear @ITernovtsiy ,

  • can I filter by several IsFieldEmpty ?
  • can I filter by several Subtrees ?

Yohann

YohannsMonnier avatar Feb 15 '21 12:02 YohannsMonnier

@YohannsMonnier no, it would require an implementation of LogicalAnd and LogicalOr filters. And, query types are designed for more advanced searches like this.

ITernovtsii avatar Feb 15 '21 12:02 ITernovtsii