You are here

public function SubrequestExtractionController::extract in GraphQL 8.4

Same name and namespace in other branches
  1. 8.3 src/Controller/SubrequestExtractionController.php \Drupal\graphql\Controller\SubrequestExtractionController::extract()

Extracts the sub-request callback response.

Return value

\Drupal\graphql\SubRequestResponse The sub-request response object.

File

src/Controller/SubrequestExtractionController.php, line 69

Class

SubrequestExtractionController
Extract arbitrary information from subrequests.

Namespace

Drupal\graphql\Controller

Code

public function extract() {
  $request = $this->requestStack
    ->getCurrentRequest();
  $callback = $request->attributes
    ->get('_graphql_subrequest');
  $metadata = new CacheableMetadata();
  $response = new SubRequestResponse($callback($metadata));
  $response
    ->addCacheableDependency($metadata);
  return $response;
}