apk
apk

Reputation: 11

cant use any filter parameters on graphql in strapi

I have been unable to use any of the filter parameters on graphl query in strapi using the url (http://localhost:1337/graphql). I am using strapi 3.6.8 . I have a collection (Animals) that has an array of Habitat. When I try to limit the number of Habitat returned for each record to 3, it doesn't work with the query below.

query{
        Animals {
          id
          Habitat(limit: 3) {
            Feature {
              Weight
              Height
              Lifespan
            }
          }
        }
      }

I get the error message: "Unknown argument "limit" on field "Animal.Habitat"."

the limit, where or any other filter does not work. They work however when I use them on the Animals itself. Kindly help

Upvotes: 1

Views: 497

Answers (1)

see saw
see saw

Reputation: 21

If you are on graphql playground, try pressing CTRL + SPACE and you will see the available parameters that you can use inside your query. In your case, I assume you want to use the pagination feature provided by Strapi. The following query should work.

query {
  Animals {
    id
    Habitat(pagination: { limit: 3 }) {
      Feature {
        Weight
        Height
        Lifespan
      }
    }
  }
}

Upvotes: 1

Related Questions