countries icon indicating copy to clipboard operation
countries copied to clipboard

Batching requests is not supported anymore

Open leszekhanusz opened this issue 1 year ago • 5 comments

It was working in September when we developed the functionality for the gql Python client.

Could it be possible to bring that functionality back?

In the meantime, I'm disabling those tests on our side.

leszekhanusz avatar Jan 02 '24 23:01 leszekhanusz

Hey there! I think this was due to this API switching from Apollo Server to GraphQL Yoga a little while ago. And it seems like batching is disabled by default in Yoga: https://the-guild.dev/graphql/yoga-server/docs/features/request-batching

So I made a commit that enables it: https://github.com/trevorblades/countries/commit/398df276b8953dee739133f98e178659c6804eb1

Hope that helps :)

trevorblades avatar Jan 03 '24 19:01 trevorblades

Hey, Thanks! I notice though that it works now on the endpoint https://countries.trevorblades.workers.dev/graphql but not on https://countries.trevorblades.com/graphql Is that normal?

leszekhanusz avatar Jan 03 '24 20:01 leszekhanusz

Ah, I see what's going on. I recently introduced a rate limit to deal with some users abusing the API by sending 100s of uncachable, erroneous requests per second, and blowing up my Cloudflare workers free usage limit as a result. Unfortunately, batch queries is currently incompatible with Stellate's rate limiting feature: https://stellate.co/docs/graphql-rate-limiting/alpha-limitations#graph-ql-query-batching

I really want to support this feature, but I also know that unless I have another plan in place to deal with spamming requests, disabling rate limiting will cause the entire API to be unresponsive once per day, if it continues to get hammered by invalid requests.

Perhaps there's yet another (hopefully free) service I can put infront of Stellate to deal with the rate limiting issue. Would appreciate any ideas or recommendations, if you have any!

trevorblades avatar Jan 03 '24 21:01 trevorblades

I understand. Sorry I don't have any recommendations.

leszekhanusz avatar Jan 03 '24 21:01 leszekhanusz

No worries! I'll keep thinking about this and hopefully come up with a good solution soon. I'll post back here with any updates. Thanks for bringing this to my attention!

trevorblades avatar Jan 03 '24 22:01 trevorblades