-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Example of custom order field in graphql without reloadind the order
- Loading branch information
1 parent
babf55a
commit b9cc55d
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/** | ||
* Copyright © MageWorx. All rights reserved. | ||
* See LICENSE.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace MageWorx\ExtendedCartGraphQl\Model\Resolver; | ||
|
||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
|
||
class OrderCustomField implements \Magento\Framework\GraphQl\Query\ResolverInterface | ||
{ | ||
/** | ||
* @inheritDoc | ||
*/ | ||
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null) | ||
{ | ||
if (!isset($value['model'])) { | ||
throw new LocalizedException(__('"model" value should be specified')); | ||
} | ||
/** @var \Magento\Sales\Api\Data\OrderInterface $order */ | ||
$order = $value['model']; | ||
|
||
return (string)$order->getData('your_custom_field'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters