Open paales opened 3 years ago
Hi @paales. Thank you for your report. To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.4-develop instance
- upcoming 2.4.x release
For more details, please, review the Magento Contributor Assistant documentation.
Please, add a comment to assign the issue: @magento I am working on this
Join Magento Community Engineering Slack and ask your questions in #github channel.
:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
:clock10: You can find the schedule on the Magento Community Calendar page.
:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.
:movie_camera: You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel
:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!
This isn't stale
Hi @engcom-Lima. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.4-develop
branchDetails
- Add the comment @magento give me 2.4-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.4-develop
branch, please, add the label Reproduced on 2.4.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Add label Issue: Confirmed
once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hi @paales ,
default query complexity and depth thresholds are configurable via the magento2/app/code/Magento/GraphQl/etc/di.xml file.
So you are free to adjust these values as deemed fit for your environment. This is the current approach we advocate to users and will have improved in the upcoming 2.4.3 release.
Thanks
@engcom-Lima Thanks for the suggestion to modify those values! Changing the defaults would still make sense, right? Or is that what you mentioned for 2.4.3?
This needs to be put in the core, we can have the configuration as it is. Doing an integration or consuming the GraphQL right now, makes the usage of the API totally worthless.
@engcom-Lima Can you elaborate on the improvements for 2.4.3? I'm currently on this version, and still find myself running into the queryComplexity limit that seems to be set to 300.
For our application to remain compatible with standard Magento (that is, without requiring one to change the default limits through DI customisation) this would require splitting up such queries, which only introduces more overhead and takes away one of the benefits of GraphQL
300 is still set as the default query complexity limit. This really ought to be assessed.
2.4-develop
2.5-develop
It's not difficult to change in a project, but also not difficult to set a more reasonable default that reduces the chance of devs chasing their tails because of this.
Preconditions (*)
Steps to reproduce (*)
I'm trying to fetch all product information for the product page in one go:
When I run this query I get an error:
Max query complexity should be 300 but got 388.
Expected result (*)
I'm not doing anything super special and I would expect this to succeed. Especially since the workaround is that I need to make two calls to the Magento backend which will invariably cause more load for the server.
Actual result (*)
The current complexity limit is set to 300: https://github.com/magento/magento2/blob/3ad7a1d3919095cfd432837c148573d5d5be66bf/app/code/Magento/GraphQl/etc/di.xml#L102-L103
There currently is a test set to validate that it isn't more than 300:
https://github.com/magento/magento2/blob/3ad7a1d3919095cfd432837c148573d5d5be66bf/dev/tests/api-functional/testsuite/Magento/GraphQl/Framework/QueryComplexityLimiterTest.php#L398
It seems that the
queryDepth
here is set relatively high, but thequeryComplexity
is set relatively low.Proposed solution
Apollo
If we read this security post from Apollo https://www.apollographql.com/blog/securing-your-graphql-api-from-malicious-queries-16130a324a6b/, it seems more sensible values would be:
graphql-query-complexity library
If we follow the defaults mentioned here: https://github.com/slicknode/graphql-query-complexity/blob/95e2899dd9bc32600114dd04bef5996ceeba0f4a/README.md#usage, we get:
Hasura
Hasura doesn't even offer queryComplexity limits they only offer queryDepth limits:
https://hasura.io/docs/latest/graphql/cloud/api-limits.html#configuring-an-api-limit
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.