public function ThunderEntitySubRequest::resolve in Thunder 6.2.x
Resolve data from a sub request.
Parameters
string $path: The path to request.
string $key: The key, where the data is stored in the sub request.
\Drupal\Core\Cache\RefinableCacheableDependencyInterface $metadata: The cacheable dependency interface.
Return value
mixed The data.
Throws
\Drupal\Core\Entity\EntityMalformedException
File
- modules/
thunder_gqls/ src/ Plugin/ GraphQL/ DataProducer/ ThunderEntitySubRequest.php, line 94
Class
- ThunderEntitySubRequest
- Get data from a sub request to the URL of an entity.
Namespace
Drupal\thunder_gqls\Plugin\GraphQL\DataProducerCode
public function resolve(string $path, string $key, RefinableCacheableDependencyInterface $metadata) {
$request = Request::create($path, 'GET', [
MainContentViewSubscriber::WRAPPER_FORMAT => 'thunder_gqls',
]);
/** @var \Symfony\Component\HttpFoundation\JsonResponse $response */
$response = $this->httpKernel
->handle($request);
if ($response
->getStatusCode() !== 200) {
return '';
}
$content = (string) $response
->getContent();
return Json::decode($content)[$key];
}