public function GraphQLFileTestTrait::requestWithQueryFile in GraphQL 8.3
Run http subrequest with a specific query file.
Parameters
string $queryFile: The query file name.
mixed $variables: Variables to be passed to the query file.
bool $assertNoErrors: Assert the absence of errors.
Return value
array The GraphQL result object.
Throws
\Exception
File
- tests/
src/ Traits/ GraphQLFileTestTrait.php, line 65
Class
- GraphQLFileTestTrait
- Trait for running tests against GraphQL query files.
Namespace
Drupal\Tests\graphql\TraitsCode
public function requestWithQueryFile($queryFile, $variables = [], $assertNoErrors = TRUE) {
$content = [
'query' => $this
->getQuery($queryFile),
'variables' => $variables,
];
/** @var \Symfony\Component\HttpKernel\HttpKernelInterface $httpKernel */
$httpKernel = \Drupal::service('http_kernel');
$response = $httpKernel
->handle(Request::create('/graphql', 'POST', [], [], [], [], json_encode($content)));
$data = json_decode($response
->getContent(), TRUE);
if ($assertNoErrors) {
$this
->assertNoErrors($data);
}
return $data;
}