You are here

protected function HttpRequestTrait::batchedQueries in GraphQL 8.4

Same name and namespace in other branches
  1. 8.3 tests/src/Traits/HttpRequestTrait.php \Drupal\Tests\graphql\Traits\HttpRequestTrait::batchedQueries()

Simulate batched queries over http.

Parameters

array[] $queries: A set of queries to be executed in one go.

\Drupal\graphql\Entity\ServerInterface $server: The server instance.

Return value

\Symfony\Component\HttpFoundation\Response The http response object.

3 calls to HttpRequestTrait::batchedQueries()
PermissionsTest::testFullQueryAccess in tests/src/Kernel/Framework/PermissionsTest.php
Test access to arbitrary queries.
PermissionsTest::testNoPermissions in tests/src/Kernel/Framework/PermissionsTest.php
Test if a user without permissions doesn't have access to any query.
ResultTest::testBatchedQueries in tests/src/Kernel/Framework/ResultTest.php
Test a batched query result.

File

tests/src/Traits/HttpRequestTrait.php, line 68

Class

HttpRequestTrait
Test trait for the GraphQL HTTP interface.

Namespace

Drupal\Tests\graphql\Traits

Code

protected function batchedQueries(array $queries, ServerInterface $server = NULL) {
  $server = $server ?: $this->server;
  if (!$server instanceof Server) {
    throw new \LogicException('Invalid server.');
  }
  $queries = json_encode($queries);
  $endpoint = $this->server
    ->get('endpoint');
  $request = Request::create($endpoint, 'POST', [], [], [], [], $queries);
  return $this->container
    ->get('http_kernel')
    ->handle($request);
}