-
Notifications
You must be signed in to change notification settings - Fork 9.4k
GraphQL CORS Headers #28713
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
GraphQL CORS Headers #28713
Conversation
Hi @michalderlatka. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. |
@magento run all tests |
3db87dc
to
50635d9
Compare
app/code/Magento/GraphQl/Controller/HttpResponse/Cors/AbstractCorsHeaderProvider.php
Outdated
Show resolved
Hide resolved
app/code/Magento/GraphQl/Controller/HttpResponse/Cors/CorsAllowHeadersHeaderProvider.php
Outdated
Show resolved
Hide resolved
app/code/Magento/GraphQl/Controller/HttpResponse/Cors/CorsAllowHeadersHeaderProvider.php
Show resolved
Hide resolved
app/code/Magento/GraphQl/Controller/HttpResponse/Cors/CorsAllowHeadersHeaderProvider.php
Outdated
Show resolved
Hide resolved
app/code/Magento/GraphQl/Controller/HttpResponse/Cors/CorsAllowMethodsHeaderProvider.php
Show resolved
Hide resolved
app/code/Magento/GraphQl/Controller/HttpResponse/Cors/CorsMaxAgeHeaderProvider.php
Outdated
Show resolved
Hide resolved
app/code/Magento/GraphQl/Controller/HttpResponse/Cors/CorsAllowCredentialsHeaderProvider.php
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a few "static failures" that need addressing,
you'll see them in the builds that I just just ran https://github.com/magento/magento2/pull/28713/checks?check_run_id=797040005
app/code/Magento/GraphQl/Controller/HttpResponse/Cors/CorsAllowHeadersHeaderProvider.php
Show resolved
Hide resolved
@magento run all tests |
…ka/magento2 into 28561_graphql_cors_requests
@magento run all tests |
@magento run all tests |
* | ||
* @return bool | ||
*/ | ||
public function isEnabled() : bool; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant space after )
and before :
.
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
const XML_PATH_CORS_HEADERS_ENABLED = 'graphql/cors/enabled'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constants should have visibility scope.
* | ||
* @return string | ||
*/ | ||
public function getName() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method return type is missed.
app/code/Magento/GraphQl/etc/di.xml
Outdated
@@ -98,4 +98,31 @@ | |||
<argument name="queryComplexity" xsi:type="number">300</argument> | |||
</arguments> | |||
</type> | |||
|
|||
<preference for="Magento\GraphQl\Model\Cors\ConfigurationInterface" type="Magento\GraphQl\Model\Cors\Configuration" /> | |||
<type name="\Magento\GraphQl\Controller\HttpResponse\Cors\CorsMaxAgeHeaderProvider"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant \
in FQCN.
|
||
protected function tearDown(): void | ||
{ | ||
parent::tearDown(); // TODO: Change the autogenerated stub |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TODO
annotations should be removed from code.
self::assertArrayNotHasKey('Access-Control-Allow-Origin', $headers); | ||
} | ||
|
||
private function getHeadersFromIntrospectionQuery() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method return type is missed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't usually do it on tests, but since we upgraded phpunit we might have to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't matter if a method is a test class method or a regular code. All code should follow the same semantic, the only exception is doc blocks, they can be omitted for test methods.
self::assertArrayNotHasKey('Access-Control-Allow-Origin', $headers); | ||
} | ||
|
||
private function getHeadersFromIntrospectionQuery() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't usually do it on tests, but since we upgraded phpunit we might have to
@magento run all tests |
Hi @michalderlatka, thank you for your contribution! |
Description (*)
As a web developer, I want Magento to support the CORS standard so that I can develop my applications according to defined best practices.
Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
Contribution checklist (*)