You are here

protected function SubRequestBuffer::createRequest in GraphQL 8.3

Create a sub-request for the given url.

Parameters

\Symfony\Component\HttpFoundation\Request $current: The current main request.

string $url: The url to run the subrequest on.

array $buffer: The buffer.

Return value

\Symfony\Component\HttpFoundation\Request The request object.

1 call to SubRequestBuffer::createRequest()
SubRequestBuffer::resolveBufferArray in src/GraphQL/Buffers/SubRequestBuffer.php
Resolve the buffer as an array.

File

src/GraphQL/Buffers/SubRequestBuffer.php, line 91

Class

SubRequestBuffer

Namespace

Drupal\graphql\GraphQL\Buffers

Code

protected function createRequest(Request $current, array $buffer, $url) {
  $request = Request::create($url, 'GET', $current->query
    ->all(), $current->cookies
    ->all(), $current->files
    ->all(), $current->server
    ->all());
  $request->attributes
    ->set('_graphql_subrequest', function () use ($buffer) {
    return array_map(function ($item) {
      return $item['extract']($item['url']);
    }, $buffer);
  });
  if ($session = $current
    ->getSession()) {
    $request
      ->setSession($session);
  }
  return $request;
}