GithubHelp home page GithubHelp logo

rate-limit tools about graphql.js HOT 15 CLOSED

iliakan avatar iliakan commented on August 25, 2024 3
rate-limit tools

from graphql.js.

Comments (15)

gr2m avatar gr2m commented on August 25, 2024

Not directly for the @octokit/graphql method. But we do have a plugin for @octokit/rest: https://github.com/octokit/plugin-throttling.js

Let me get back to you on how to use the plugin with @octokit/graphql, it’s not straight forward at this point. I’m currently working on other things so it will take a while I’m afraid. But if you want to look into it yourself and have any questions, I’d be happy to help you out

from graphql.js.

iliakan avatar iliakan commented on August 25, 2024

That's looks straight to the point!

I guess, @octokit/rest does not include @octokit/graphql.
Would be great if I could use this plugin.

from graphql.js.

gr2m avatar gr2m commented on August 25, 2024

https://github.com/octokit/plugin-throttling.js does include special throttling for @octokit/graphql now. It’s still not usable with @octokit/rest, but if you don’t want to wait, here is how we use it in probot:

https://github.com/probot/probot/blob/8f86e8d1c82f7ac94899f97b0104fa9a8b7c5b48/src/github/graphql.ts#L18-L22

Note that it’s using internal APIs, so make sure to pin the @octokit/graphql version for the time being

from graphql.js.

gr2m avatar gr2m commented on August 25, 2024

I'm working on the Octokit Core library which will include the .graphql method, but also the plugin API. So you will be able to load the throttle plugin.

Initial version should be ready soon: octokit/core.js#3

from graphql.js.

foolip avatar foolip commented on August 25, 2024

octokit/core.js#3 is resolved now, does that mean this is ready for action now? Examples of how to integrate with @octokit/graphql would be great!

from graphql.js.

gr2m avatar gr2m commented on August 25, 2024

I'm open to suggestions. Throttling with GraphQL is much more complicated then it is with REST. @ReaLoretta gave a great talk on advanced GraphQL patterns such as this at GitHub Universe: https://www.youtube.com/watch?v=i5pIszu9MeM.

We are looking into creating a GraphQL pagination plugin too: octokit/plugin-paginate-graphql.js#1

from graphql.js.

kevindigo avatar kevindigo commented on August 25, 2024

We're about to dive into some octokit graphql work. What is the recommended way to perform simple throttling/rate limiting at this point?

from graphql.js.

gr2m avatar gr2m commented on August 25, 2024

Use the throttle plugin, it has some throttle logic specific to GraphQL built in, but I don't think it covers it all yet. As mentioned above GraphQL is much more complicated compared to the REST API, throttling alone won't help you if your queries are to complex. Make sure to watch Rea's talk that I've linked above.

The original issue is resolved, so I'm going to close the issue. @octokit/rest is now built on @octokit/core, both can utilize the throttle plugin in the same way.

from graphql.js.

dan-kez avatar dan-kez commented on August 25, 2024

Apologies for pulling on an old thread, I've been looking through the repo and it's not clear to me how to integrate a plugin with the current graphql implementation. Is there a way to pass an Octokit instance to this library that I am missing?

from graphql.js.

gr2m avatar gr2m commented on August 25, 2024

This library exports a stateless graphql function. You can use @octokit/core, which includes the octokit.graphql method on each instance

from graphql.js.

tony avatar tony commented on August 25, 2024

Hi! I also stumbled upon this thread and don't see a solution to this issue.

Proposal: Can this be reopened until someone contributes a functional code example of @octokit/graphql.js with rate limiting / retrying / etc?

from graphql.js.

gr2m avatar gr2m commented on August 25, 2024

https://github.com/octokit/plugin-throttling.js/ and https://github.com/octokit/plugin-retry.js now both handle GraphQL queries. We recommend you use the octokit package which has it all included

import { Octokit } from "octokit"
const octokit = new Octokit({ auth: TOKEN })
const result = await octokit.graphql(query, variables)

from graphql.js.

Mickaz89-SWM avatar Mickaz89-SWM commented on August 25, 2024

In order to use the plugin-throttling , we moved from the @octokit/graphql package to the "octokit" package like the example . We now able to use throttle with graphql but we are getting now a warning in the console browser :

Screenshot 2024-08-11 at 10 45 15

Someone know why the browser interpret the module as Node Js module ?

from graphql.js.

wolfy1339 avatar wolfy1339 commented on August 25, 2024

Please use the ESM.sh build for browser usage.

import { Octokit } from "https://esm.sh/octokit";

from graphql.js.

Mickaz89-SWM avatar Mickaz89-SWM commented on August 25, 2024

Please use the ESM.sh build for browser usage.

import { Octokit } from "https://esm.sh/octokit";

How i am supposed to install it ?
Currently getting :
Cannot find module 'https://esm.sh/octokit' or its corresponding type declarations.ts(2307)

from graphql.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.