Hadezuka
Hadezuka

Reputation: 353

strapi graphql limit only return 100 items even if I set limit to -1

currently I have some problem with strapi graphql query. I can only query about 100 items max.

here is my query: query StudioList { studios(limit: -1) { id slug name } }

with or without limit always return 100 items. how do i query for more than 100? thanks..

Upvotes: 2

Views: 5418

Answers (3)

Hadezuka
Hadezuka

Reputation: 353

I found the solution (this is for old version, 2020 version, i don't remember): if you have plugins.js file in your strapi ./config folder, then add the following code:

module.exports = {
  //
  graphql: {
    endpoint: '/graphql',
    shadowCRUD: true,
    playgroundAlways: false,
    depthLimit: 7,
    amountLimit: 2500,
    apolloServer: {
      tracing: false,
    },
  },
};

change the amountlimit to whatever you want.. then restart the server, now it should shows more than 100 items.

Upvotes: 7

Mike Axle
Mike Axle

Reputation: 1097

I am using Strapi v4 (with TypeScript) and none of these solutions worked for me. I must mention that I am using custom GraphQL resolvers though.

What did work for me was changing the defaultLimit and maxLimit in this file config/api.ts

the file looks like this:

export default {
  rest: {
    defaultLimit: 1000,
    maxLimit: 2000,
    withCount: true,
  },
};

Upvotes: 0

Kamy
Kamy

Reputation: 1

I try with version of strap 3.6.8 but that's doesn't work. I rebuild strapi "npm build" & "yarn develop"

module.exports = {
  //
  graphql: {
    endpoint: '/graphql',
    shadowCRUD: true,
    playgroundAlways: false,
    depthLimit: 7,
    amountLimit: 2500,
    apolloServer: {
      tracing: false,
    },
  },
};

Upvotes: 0

Related Questions