Skip to content

Commit 6e0222e

Browse files
authored
Merge pull request #61 from dimitriBouteille/feature/graphql-support
💎 Add graphQL support
2 parents efafa2a + b10a82e commit 6e0222e

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
/**
3+
* Copyright © iMi digital GmbH, based on work by MageSpecialist
4+
* See LICENSE for license details.
5+
*/
6+
7+
namespace IMI\FriendlyCaptcha\Model\Resolver\StoreConfig;
8+
9+
use IMI\FriendlyCaptcha\Model\Config;
10+
11+
class CaptchaEnabled implements ResolverInterface
12+
{
13+
/**
14+
* @var Config
15+
*/
16+
private $config;
17+
18+
/**
19+
* CaptchaEnabled Constructor
20+
*
21+
* @param Config $config
22+
*/
23+
public function __construct(
24+
Config $config
25+
) {
26+
$this->config = $config;
27+
}
28+
29+
/**
30+
* @inheritDoc
31+
*/
32+
public function resolve(
33+
Field $field,
34+
$context,
35+
ResolveInfo $info,
36+
array $value = null,
37+
array $args = null
38+
) {
39+
return $this->config->isEnabledFrontend();
40+
}
41+
}

etc/adminhtml/system.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
showInDefault="1" showInWebsite="0" showInStore="0" canRestore="1">
5656
<label>Trusted IPS</label>
5757
<tooltip>Friendly captcha will be disabled for the specified IP addresses</tooltip>
58-
<comment><![CDATA[For example: <strong>192.168.1.2</strong> </br>Each IP must be seperated by comma]]></comment>
58+
<comment><![CDATA[For example: <strong>192.168.1.2</strong>, each IP must be separated by comma.<br>This is currently not supported when using the plugin via GraphQL]]></comment>
5959
</field>
6060
</group>
6161
<group id="frontend" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1"

etc/graphql/di.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0"?>
2+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
4+
<type name="Magento\StoreGraphQl\Model\Resolver\Store\StoreConfigDataProvider">
5+
<arguments>
6+
<argument name="extendedConfigData" xsi:type="array">
7+
<item name="imi_friendly_captcha_sitekey" xsi:type="string">imi_friendly_captcha/general/sitekey</item>
8+
</argument>
9+
</arguments>
10+
</type>
11+
</config>

etc/schema.graphqls

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type StoreConfig {
2+
imi_friendly_captcha_sitekey: String
3+
@doc(description: "Friendly Captcha Site Key")
4+
imi_friendly_captcha_enabled: Boolean
5+
@resolver(class: "IMI\\FriendlyCaptcha\\Model\\Resolver\\StoreConfig\\CaptchaEnabled")
6+
@doc(description: "Return true if Friendly Captcha is enabled")
7+
}

0 commit comments

Comments
 (0)