Return everything if filter variable is empty?

System Information
  • Strapi Version: v4.0.2
  • Operating System: Windows 10
  • Database: SQLite
  • Node Version: v16.13.2
  • NPM Version: 8.1.2
  • Yarn Version: v1.22.17

Hello, I’m a beginner Strapi user and a beginner developer too… so sorry if this is a dumb question.

I have this simple query :

query posts($category: String) {
  posts(filters: { category: { Name: { eq: $category } } }) {
    data {

with this variable :

  "category": "Image"

It works if the variable is “Image” or any other category that I have, but if the variable is empty (“category”: “”), Strapi returns an empty array, when I would like it to return all posts ids from all categories, aka just ignore the filter completely…

Can Strapi do this? Or do I have to write a second query without the filter in my front?

Thank you :pray: