diff --git a/src/fields/Matrix.php b/src/fields/Matrix.php index 2195f5a8933..56cc8f46074 100644 --- a/src/fields/Matrix.php +++ b/src/fields/Matrix.php @@ -776,7 +776,7 @@ public function getContentGqlType() $typeArray = MatrixBlockTypeGenerator::generateTypes($this); $typeName = $this->handle . '_MatrixField'; $resolver = function (MatrixBlockElement $value) { - return GqlEntityRegistry::getEntity($value->getGqlTypeName()); + return $value->getGqlTypeName(); }; return [ diff --git a/src/gql/interfaces/Element.php b/src/gql/interfaces/Element.php index 5e90d804734..c4d2f50c354 100644 --- a/src/gql/interfaces/Element.php +++ b/src/gql/interfaces/Element.php @@ -46,7 +46,7 @@ public static function getType($fields = null): Type 'fields' => self::class . '::getFieldDefinitions', 'description' => 'This is the interface implemented by all elements.', 'resolveType' => function (ElementInterface $value) { - return GqlEntityRegistry::getEntity($value->getGqlTypeName()); + return $value->getGqlTypeName(); } ])); diff --git a/src/gql/interfaces/elements/Asset.php b/src/gql/interfaces/elements/Asset.php index 31e108773fe..3c6406132ef 100644 --- a/src/gql/interfaces/elements/Asset.php +++ b/src/gql/interfaces/elements/Asset.php @@ -47,7 +47,7 @@ public static function getType($fields = null): Type 'fields' => self::class . '::getFieldDefinitions', 'description' => 'This is the interface implemented by all assets.', 'resolveType' => function (AssetElement $value) { - return GqlEntityRegistry::getEntity($value->getGqlTypeName()); + return $value->getGqlTypeName(); } ])); diff --git a/src/gql/interfaces/elements/Category.php b/src/gql/interfaces/elements/Category.php index b1ea858a9fe..f449bd0da12 100644 --- a/src/gql/interfaces/elements/Category.php +++ b/src/gql/interfaces/elements/Category.php @@ -47,7 +47,7 @@ public static function getType($fields = null): Type 'fields' => self::class . '::getFieldDefinitions', 'description' => 'This is the interface implemented by all categories.', 'resolveType' => function (CategoryElement $value) { - return GqlEntityRegistry::getEntity($value->getGqlTypeName()); + return $value->getGqlTypeName(); } ])); diff --git a/src/gql/interfaces/elements/Entry.php b/src/gql/interfaces/elements/Entry.php index 859277ebb40..9cd66d24c72 100644 --- a/src/gql/interfaces/elements/Entry.php +++ b/src/gql/interfaces/elements/Entry.php @@ -49,7 +49,7 @@ public static function getType($fields = null): Type 'fields' => self::class . '::getFieldDefinitions', 'description' => 'This is the interface implemented by all entries.', 'resolveType' => function (EntryElement $value) { - return GqlEntityRegistry::getEntity($value->getGqlTypeName()); + return $value->getGqlTypeName(); } ])); diff --git a/src/gql/interfaces/elements/GlobalSet.php b/src/gql/interfaces/elements/GlobalSet.php index efc35c8c529..55355ef461f 100644 --- a/src/gql/interfaces/elements/GlobalSet.php +++ b/src/gql/interfaces/elements/GlobalSet.php @@ -45,7 +45,7 @@ public static function getType($fields = null): Type 'fields' => self::class . '::getFieldDefinitions', 'description' => 'This is the interface implemented by all global sets.', 'resolveType' => function (GlobalSetElement $value) { - return GqlEntityRegistry::getEntity($value->getGqlTypeName()); + return $value->getGqlTypeName(); } ])); diff --git a/src/gql/interfaces/elements/MatrixBlock.php b/src/gql/interfaces/elements/MatrixBlock.php index 6119ac0a24c..2a5b1f6eea5 100644 --- a/src/gql/interfaces/elements/MatrixBlock.php +++ b/src/gql/interfaces/elements/MatrixBlock.php @@ -45,7 +45,7 @@ public static function getType($fields = null): Type 'fields' => self::class . '::getFieldDefinitions', 'description' => 'This is the interface implemented by all matrix blocks.', 'resolveType' => function (MatrixBlockElement $value) { - return GqlEntityRegistry::getEntity($value->getGqlTypeName()); + return $value->getGqlTypeName(); } ])); diff --git a/src/gql/interfaces/elements/Tag.php b/src/gql/interfaces/elements/Tag.php index a68c244e0e0..f0257540a33 100644 --- a/src/gql/interfaces/elements/Tag.php +++ b/src/gql/interfaces/elements/Tag.php @@ -45,7 +45,7 @@ public static function getType($fields = null): Type 'fields' => self::class . '::getFieldDefinitions', 'description' => 'This is the interface implemented by all tags.', 'resolveType' => function (TagElement $value) { - return GqlEntityRegistry::getEntity($value->getGqlTypeName()); + return $value->getGqlTypeName(); } ])); diff --git a/src/gql/interfaces/elements/User.php b/src/gql/interfaces/elements/User.php index 8ab7a3a9361..049d9d896e2 100644 --- a/src/gql/interfaces/elements/User.php +++ b/src/gql/interfaces/elements/User.php @@ -47,7 +47,7 @@ public static function getType($fields = null): Type 'fields' => self::class . '::getFieldDefinitions', 'description' => 'This is the interface implemented by all users.', 'resolveType' => function (UserElement $value) { - return GqlEntityRegistry::getEntity($value->getGqlTypeName()); + return $value->getGqlTypeName(); } ])); diff --git a/src/services/Gql.php b/src/services/Gql.php index dacb1382360..f7001804ab6 100644 --- a/src/services/Gql.php +++ b/src/services/Gql.php @@ -170,17 +170,6 @@ public function getSchemaDef(GqlSchema $schema = null, $prebuildSchema = false): 'directives' => $this->_loadGqlDirectives(), ]; - // For some reason, matrix types need to be explicitly defined, too, - // otherwise it will complain on querying matrix blocks - $typeGeneratorClass = MatrixBlockInterface::getTypeGenerator(); - - foreach ($typeGeneratorClass::generateTypes() as $type) { - $schemaConfig['types'][] = $type; - } - - // TODO fire an event to allow modifying the $schemConfig. - // At least one use-case being adding workaround like for Matrix above. - // If we're not required to pre-build the schema the relevant GraphQL types will be added to the Schema // as the query is being resolved thanks to the magic of lazy-loading, so we needn't worry. if (!$prebuildSchema) {