You are here

protected function ThunderGqlsTestBase::query in Thunder 6.2.x

Queries the graphql api.

Parameters

string $query: The GraphQl query to execute.

string $variables: The variables for the query.

Return value

\Psr\Http\Message\ResponseInterface The response.

Throws

\GuzzleHttp\Exception\GuzzleException

3 calls to ThunderGqlsTestBase::query()
SchemaTest::testExpiredImage in modules/thunder_gqls/tests/src/Functional/SchemaTest.php
Tests the article with an expired teaser image.
SchemaTest::testUnpublishedAccess in modules/thunder_gqls/tests/src/Functional/SchemaTest.php
Tests the article schema.
ThunderGqlsTestBase::runAndTestQuery in modules/thunder_gqls/tests/src/Functional/ThunderGqlsTestBase.php
Execute query and compare to expected response.

File

modules/thunder_gqls/tests/src/Functional/ThunderGqlsTestBase.php, line 71

Class

ThunderGqlsTestBase
The base class for all functional Thunder GraphQl schema tests.

Namespace

Drupal\Tests\thunder_gqls\Functional

Code

protected function query(string $query, string $variables) : ResponseInterface {
  $urlGenerator = $this->container
    ->get('url_generator');
  $url = $urlGenerator
    ->generate('graphql.query.thunder_graphql');
  $requestOptions = [];
  $requestOptions[RequestOptions::HEADERS]['Content-Type'] = 'application/json';
  $requestOptions[RequestOptions::COOKIES] = $this
    ->getSessionCookies();
  $requestOptions[RequestOptions::JSON]['query'] = $query;
  $requestOptions[RequestOptions::JSON]['variables'] = $variables;
  return $this
    ->getHttpClient()
    ->request('POST', $this
    ->getAbsoluteUrl($url), $requestOptions);
}