trait HttpRequestTrait in GraphQL 8.3
Same name and namespace in other branches
- 8.4 tests/src/Traits/HttpRequestTrait.php \Drupal\Tests\graphql\Traits\HttpRequestTrait
Test trait for the GraphQL HTTP interface.
Hierarchy
- trait \Drupal\Tests\graphql\Traits\HttpRequestTrait
1 file declares its use of HttpRequestTrait
- GraphQLTestBase.php in tests/
src/ Kernel/ GraphQLTestBase.php
File
- tests/
src/ Traits/ HttpRequestTrait.php, line 10
Namespace
Drupal\Tests\graphql\TraitsView source
trait HttpRequestTrait {
/**
* Issue a simple query over http.
*
* @param string $query
* The query string.
* @param array $variables
* Query variables.
*
* @return \Symfony\Component\HttpFoundation\Response
* The http response object.
*/
protected function query($query, array $variables = []) {
return $this->container
->get('http_kernel')
->handle(Request::create('/graphql', 'GET', [
'query' => $query,
'variables' => $variables,
]));
}
/**
* Issue a persisted query over http.
*
* @param $id
* The query id.
* @param array $variables
* Query variables.
*
* @return \Symfony\Component\HttpFoundation\Response
* The http response object.
*/
protected function persistedQuery($id, array $variables = []) {
return $this->container
->get('http_kernel')
->handle(Request::create('/graphql', 'GET', [
'queryId' => $id,
'variables' => $variables,
]));
}
/**
* Simulate batched queries over http.
*
* @param string[] $queries
* A set of queries to be executed in one go.
*
* @return \Symfony\Component\HttpFoundation\Response
* The http response object.
*/
protected function batchedQueries($queries) {
return $this->container
->get('http_kernel')
->handle(Request::create('/graphql', 'POST', [], [], [], [], json_encode($queries)));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HttpRequestTrait:: |
protected | function | Simulate batched queries over http. | |
HttpRequestTrait:: |
protected | function | Issue a persisted query over http. | |
HttpRequestTrait:: |
protected | function | Issue a simple query over http. |