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

[GRAPHQL] Add configurations in StoreConfig #1235

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions Model/Resolver/StoreConfig/IsEnabled.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Amazon\Pay\Model\Resolver\StoreConfig;

use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Amazon\Pay\Model\AmazonConfig;

class IsEnabled implements ResolverInterface
{
private AmazonConfig $amazonConfig;

public function __construct(
AmazonConfig $amazonConfig
) {
$this->amazonConfig = $amazonConfig;
}

/**
* @inheritDoc
*/
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
{
return $this->amazonConfig->isEnabled();
}
}
2 changes: 2 additions & 0 deletions etc/graphql/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<arguments>
<argument name="extendedConfigData" xsi:type="array">
<item name="amazon_payment_region" xsi:type="string">payment/amazon_payment/payment_region</item>
<item name="amazon_payment_minicart_button_is_visible" xsi:type="string">payment/amazon_payment/minicart_button_is_visible</item>
<item name="amazon_payment_pwa_pp_button_is_visible" xsi:type="string">payment/amazon_payment/pwa_pp_button_is_visible</item>
</argument>
</arguments>
</type>
Expand Down
5 changes: 5 additions & 0 deletions etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,9 @@ type UpdateCheckoutSessionOutput {

type StoreConfig {
amazon_payment_region: String @doc(description: "Payment Region for js import")
amazon_payment_minicart_button_is_visible: Boolean @doc(description: "True if button is configured to display in minicart")
amazon_payment_pwa_pp_button_is_visible: Boolean @doc(description: "True if button is configured to display on PDP")
amazon_payment_is_enabled: Boolean
@doc(description: "True if AP is enabled and available for customer/store")
@resolver(class: "Amazon\\Pay\\Model\\Resolver\\StoreConfig\\IsEnabled")
}