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

A way to compute/limit query complexity #902

Closed
MeRuslan opened this issue May 2, 2021 · 6 comments
Closed

A way to compute/limit query complexity #902

MeRuslan opened this issue May 2, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@MeRuslan
Copy link

MeRuslan commented May 2, 2021

A basic protection against malicious requests / scraping.

I'd love to see some means to:

  1. Set / control field/resolver complexity.
  2. Limit whole query complexity (no idea on what to do in such a case, fail or limit response, maybe have it configured by the developer).
@MeRuslan
Copy link
Author

MeRuslan commented May 2, 2021

Let's say a default field complexity is 1.
For a custom field a user can annotate its complexity using absolute values, and in terms of the query complexity down the line (i.e. children might be ORM's related objects, thus leaving the current node as a source of complexity truth for them).

Seems to me that we'll have to understand pagination at the step of complexity computation. I don't think there's a defined pagination API yet.

@MeRuslan
Copy link
Author

MeRuslan commented May 2, 2021

I'm a new one here, might be completely wrong :D

@jokull
Copy link

jokull commented May 2, 2021

@BryceBeagle BryceBeagle added the enhancement New feature or request label May 3, 2021
@jkimbo
Copy link
Member

jkimbo commented Jun 30, 2021

Closing this in favour of #960

@jkimbo jkimbo closed this as completed Jun 30, 2021
@MeRuslan
Copy link
Author

MeRuslan commented Jul 2, 2021

Closing this in favour of #960

Depth limiting would certainly help, but it does not really secure you.
Perhaps I should have worded it better.

I would also like to be able to reject a query that would result in returning thousands of objects.
For that we'd need proper query analysis, not just a simple depth limit.

I.e.
query { user(id: 1) { chats(first: 100) { message(first: 100) { ... } } } }
would pass any reasonable depth limit, but I'd like to reject a query that complex.

I imagined something like https://github.com/pa-bru/graphql-cost-analysis

@jkimbo
Copy link
Member

jkimbo commented Jul 4, 2021

Sorry @MeRuslan , by closing this issue I didn't mean to imply that we shouldn't implement cost query limits, just that I wanted to consolidate the different approaches to handling malicious queries into one issue. I've included your comment there.

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

No branches or pull requests

4 participants