nyancodeid/quotes

Github API is Limited and Slow

Closed this issue · 1 comments

We have ± 81 yaml files inside of quotes folder, and it's mean everytime we run npm run generate:quotes we have to fetch 81 times to Github API to get users detail like full a name, avatar, and follower count. Couple days ago i create a PR #60 that include an optional Github Token as a Environment Variable helped by .env / .env.local files. Why i did this? because Github API is rate limited without Authentication or Token.

Now that the rate limited problem has been solved by using tokens, now many requests make it slow. And I just realized, why don't we call it using GraphQL instead. Some may ask what is the difference between GraphQL and the REST API used today.

Well , with GraphQL, it is very possible for us to retrieve more than one user data in one request. So we can simply determine how and what data we will receive by sending a formatted query according to what is provided by Github GraphQL. So instead of sending 81 requests to the Github API we can easily get them with 1 request using Github GraphQL.

I am working on it, so stay tune.

Reference

Wow, I can see a huge difference here. The difference in their execution time is very far apart. It fast!

Different