diff --git a/CHANGELOG.md b/CHANGELOG.md index af3c7f1..a0355a1 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.0.1 - 2021-05-19 +### Fixed +- Fixed GraphQL duplicate schema issue + ## 1.0.0 - 2021-05-18 ### Added - Initial release diff --git a/composer.json b/composer.json index 22467bd..e9d937c 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "augmentations/craft-json", "description": "Field type for raw JSON editing.", "type": "craft-plugin", - "version": "1.0.0", + "version": "1.0.1", "keywords": [ "craft", "cms", diff --git a/src/fields/JsonField.php b/src/fields/JsonField.php index 550a68e..96bf0c4 100755 --- a/src/fields/JsonField.php +++ b/src/fields/JsonField.php @@ -7,6 +7,8 @@ use Craft; use craft\base\ElementInterface; use craft\base\Field; +use craft\gql\GqlEntityRegistry; +use craft\gql\TypeLoader; use craft\helpers\Html; use craft\helpers\Json; use craft\helpers\StringHelper; @@ -62,7 +64,22 @@ public function getElementValidationRules(): array */ public function getContentGqlType(): Type { - return new MixedScalar(); + $typeName = "Mixed"; + + if ($type = GqlEntityRegistry::getEntity($typeName)) { + return $type; + } + + $type = GqlEntityRegistry::createEntity( + $typeName, + new MixedScalar(["name" => $typeName]) + ); + + TypeLoader::registerType($typeName, function () use ($type) { + return $type; + }); + + return $type; } /**