Skip to content

Commit

Permalink
Fixed f4b60b6 better.
Browse files Browse the repository at this point in the history
  • Loading branch information
andris-sevcenko committed Oct 8, 2019
1 parent 72a4f23 commit 80192a5
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/fields/Matrix.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down
2 changes: 1 addition & 1 deletion src/gql/interfaces/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
]));

Expand Down
2 changes: 1 addition & 1 deletion src/gql/interfaces/elements/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
]));

Expand Down
2 changes: 1 addition & 1 deletion src/gql/interfaces/elements/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
]));

Expand Down
2 changes: 1 addition & 1 deletion src/gql/interfaces/elements/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
]));

Expand Down
2 changes: 1 addition & 1 deletion src/gql/interfaces/elements/GlobalSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
]));

Expand Down
2 changes: 1 addition & 1 deletion src/gql/interfaces/elements/MatrixBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
]));

Expand Down
2 changes: 1 addition & 1 deletion src/gql/interfaces/elements/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
]));

Expand Down
2 changes: 1 addition & 1 deletion src/gql/interfaces/elements/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
]));

Expand Down
11 changes: 0 additions & 11 deletions src/services/Gql.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 80192a5

Please sign in to comment.