Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Add generic types #567

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ protected function getRequestQueryVariables(HTTPRequest $request): array
$query = isset($data['query']) ? $data['query'] : null;
$variables = isset($data['variables']) ? (array)$data['variables'] : null;
} else {
/** @var RequestProcessor $persistedProcessor */
$persistedProcessor = Injector::inst()->get(RequestProcessor::class);
list($query, $variables) = $persistedProcessor->getRequestQueryVariables($request);
}
Expand Down
4 changes: 4 additions & 0 deletions src/Extensions/ClientConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,14 @@

namespace SilverStripe\GraphQL\Extensions;

use SilverStripe\Admin\LeftAndMain;
use SilverStripe\Core\Config\Config;
use SilverStripe\Core\Extension;
use SilverStripe\GraphQL\Controller;

/**
* @extends Extension<LeftAndMain>
*/
class ClientConfigProvider extends Extension
{
public function updateClientConfig(array &$config): void
Expand Down
4 changes: 4 additions & 0 deletions src/Extensions/DevBuildExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
use SilverStripe\Core\Injector\Injector;
use SilverStripe\GraphQL\Dev\Build;
use SilverStripe\GraphQL\Schema\Logger;
use SilverStripe\ORM\DatabaseAdmin;
use SilverStripe\ORM\DataExtension;

/**
* @extends DataExtension<DatabaseAdmin>
*/
class DevBuildExtension extends DataExtension
{
use Configurable;
Expand Down
2 changes: 2 additions & 0 deletions src/Extensions/QueryRecorderExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
/**
* Attaches itself to {@see DataQuery} and records any classes that are queried within a closure context.
* Allows code to measure and detect affected classes within any operation. E.g. for caching.
*
* @extends DataExtension<DataObject>
*/
class QueryRecorderExtension extends DataExtension
{
Expand Down
4 changes: 4 additions & 0 deletions src/Extensions/TestSessionEnvironmentExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
use SilverStripe\GraphQL\Schema\SchemaBuilder;
use SilverStripe\GraphQL\Schema\Exception\EmptySchemaException;
use SilverStripe\GraphQL\Dev\Benchmark;
use SilverStripe\TestSession\TestSessionEnvironment;

/**
* @extends Extension<TestSessionEnvironment>
*/
class TestSessionEnvironmentExtension extends Extension
{
/**
Expand Down
1 change: 0 additions & 1 deletion src/PersistedQuery/RequestIDProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public function getRequestQueryVariables(HTTPRequest $request): array
if ($query) {
throw new LogicException('Cannot pass a query when an ID has been specified.');
}
/** @var PersistedQueryMappingProvider $provider */
$provider = Injector::inst()->get(PersistedQueryMappingProvider::class);

$query = $provider->getByID($id);
Expand Down
2 changes: 0 additions & 2 deletions src/QueryHandler/QueryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ public function validateQueryBeforeParsing(string $query, array $context): void
*/
public function getQueryFromPersistedID(string $id): ?string
{
/** @var PersistedQueryMappingProvider $provider */
$provider = Injector::inst()->get(PersistedQueryMappingProvider::class);

return $provider->getByID($id);
Expand Down Expand Up @@ -291,7 +290,6 @@ protected function callMiddleware(GraphQLSchema $schema, string $query, array $c
$next = $last;
// Filter out any middlewares that are set to `false`, e.g. via config
$middlewares = array_reverse(array_filter($this->getMiddlewares() ?? []));
/** @var QueryMiddleware $middleware */
foreach ($middlewares as $middleware) {
$next = function ($schema, $query, $context, $params) use ($middleware, $next) {
return $middleware->process($schema, $query, $context, $params, $next);
Expand Down
1 change: 0 additions & 1 deletion src/Schema/DataObject/DeleteCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ public static function resolve(array $resolverContext = []): Closure
}

// Before deleting, check if any items fail canDelete()
/** @var DataObject[] $resultsList */
$resultsList = $results->toArray();
foreach ($resultsList as $obj) {
$member = UserContextProvider::get($context);
Expand Down