I need graphql to return all records
amountLimit
is implemented differently on the strapi plugin
Can somebody tell me why graphql amountLimit
was implemented like this?
amountLimiting: (params = {}) => {
const { amountLimit } = strapi.plugins.graphql.config;
if(!amountLimit) return params;
if (!params.limit || params.limit === -1 || params.limit > amountLimit) {
params.limit = amountLimit;
} else if (params.limit < 0) {
params.limit = 0;
}
return params;
},
strapi has a _limit = 0
for all records, but on graphql plugin they're adding a default limit of 100.
If I am to give limit: -1
or limit: 0
to the graphql query, it will put the default limit
of 100
.
If I am to give (else if (params.limit < 0)
) any other nr
lower than 0
, but it's not -1
, the plugin queries strapi with limit: 0
(all records)
I need a way of querying graphql for all records, yet setting the limit to -2
seems a bit random to me (as setting the limit to any -(2^31) < nr < -1
number)
Any thoughts?
DMehaffy (Not Strapi Employee) 12:35 PM
Strapi doesn't use the typical version system right now (it will when it goes stable) unable to get all entries yes. To prevent massive queries from basically locking up your server, aka DDoS. Strapi being nodejs (basically single threaded) massive one off queries is not the most effective way to pull all the data, especially in a load balancing setup grab a count, divide it up, and make multiple smaller requests at the same time or asynchronously then merge the records together client side Sure you are injecting a bit more round trip time, but in the long run it is quite a bit faster (especially when load balancing multiple strapi instances)
Apparently, in strapi version beta.17.5
the negative limit will be removed completely, thus rendering this question obsolete.
As from the Strapi response up above, they are working on a solution, but at this time, for Strapi 3.0.0-beta.14
which is my current version, the negative look-up is still available, but it will be removed, with a new solution being provided.