Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION]: batch queries doesn't seem to work #187

Open
simplecommerce opened this issue Jun 23, 2021 · 0 comments
Open

[QUESTION]: batch queries doesn't seem to work #187

simplecommerce opened this issue Jun 23, 2021 · 0 comments

Comments

@simplecommerce
Copy link

simplecommerce commented Jun 23, 2021

  • I'm submitting a ...
    [ x ] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary

I am testing the implementation of your library in our GraphQL instance and individual mutations or queries seem to work fine for rate limiting.

But if we send batch queries or mutations, it doesn't seem to count it as individual when executing.

For example, if I send a POST to my GraphQL with the following body

[
{"operationName":"Update","variables":{}},"query":"mutation Update($input: UpdateInput!) {\n  update(input: $input)\n}\n"},
{"operationName":"Update","variables":{}},"query":"mutation Update($input: UpdateInput!) {\n  update(input: $input)\n}\n"},
{"operationName":"Update","variables":{}},"query":"mutation Update($input: UpdateInput!) {\n  update(input: $input)\n}\n"},
{"operationName":"Update","variables":{}},"query":"mutation Update($input: UpdateInput!) {\n  update(input: $input)\n}\n"},
{"operationName":"Update","variables":{}},"query":"mutation Update($input: UpdateInput!) {\n  update(input: $input)\n}\n"},
]

It only counts as 1 attempt.

I am using the resolver option implementation.
What I did was put it in a middleware to run before my resolver.
I also tried directly in a resolver and the same issue happens.

I might be doing something wrong.
Any help is appreciated.

Update

I have tried implementing the schema option and I still get the same issue.
It works for single mutations but if I send a batch using Postman, it doesn't properly count for batched requests.

I tried the following library which does the same thing https://github.com/ravangen/graphql-rate-limit and this one seems to work fine with batching.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant