-
Notifications
You must be signed in to change notification settings - Fork 154
Return full canonical product URL within product object #7
Return full canonical product URL within product object #7
Conversation
$fixtureSku = 'p002'; | ||
$query = <<<QUERY | ||
{ | ||
products(filter: {sku: {eq: "$fixtureSku"}}) |
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.
Please convert this test into web API functional test.
See \Magento\GraphQl\Catalog\ProductViewTest::testQueryAllFieldsSimpleProduct as an example.
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
|
||
class CanonicalUrl implements ResolverInterface |
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.
All classes and methods should be documented.
* @param \Magento\Framework\GraphQl\Config\Element\Field $field | ||
* @param $context | ||
* @param ResolveInfo $info | ||
* @param array|null $value |
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.
Please use @inheritdoc
instead of duplicating parent annotations.
use Magento\Store\Model\StoreManagerInterface; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class CanonicalUrlTest extends TestCase |
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.
FYI, unit tests are optional and should be added only when it makes sense (e.g. when you can test method API without mocks). Since the test is already completed, we can keep it.
@austris-argalis Thank you for your contribution, feel free to contact me directly regarding requested changes at magentocommeng.slack.com (send an email to [email protected] to join). |
@paliarush thanks for the review! |
Hi @austris-argalis Thank you |
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.
PR looks good and can be merged after CLA is signed by @austris-argalis
@austris-argalis thank you for contributing. Please accept Community Contributors team invitation here to gain extended permissions for this repository. |
@austris-argalis the test failed CICD environment, please check this:
|
Hello @paliarush Thanks for the info! Been running tests on a fresh install of 2.3-develop over php 7.1.16 with mysql 5.7. also running full graphql api testsuite does not fail this particular test: |
@austris-argalis I cannot reproduce the issue locally either. Some settings must be different on the instance running tests. With current implementation, the test may still pass, while the public API changes (e.g. if we change URL generation logic). Let's rewrite the test to compare the URL to predefined static value. Such test would correctly fail if public GraphQL interface changes for some reason. Just take base URL and append "simple-product.html" to it before assertion. |
Approved ✅ |
@austris-argalis your PR has been merged, thanks for the contribution, you are the first contributor to Magento's GraphQL track! |
Added canonical_url to the Products endpoint documentation. |
update branch 2.3 develop
Update branch 2.3-develop
Magento 2.3-develop Latest Pull
Description
Added canonical URL to graphql schema along with the necessary resolvers.
Fixed Issues (if relevant)
Manual testing scenarios
curl -X POST -H "Content-Type: application/json" --data '{"query": "{products(filter: {sku: {neq: \"simple1\"}}) {items {id,canonical_url}}}","variables": [],"operationName": null}' http://magento23.local/graphql
Contribution checklist