QueryProvider.php in GraphQL 8.3
File
src/GraphQL/QueryProvider/QueryProvider.php
View source
<?php
namespace Drupal\graphql\GraphQL\QueryProvider;
use GraphQL\Server\OperationParams;
class QueryProvider implements QueryProviderInterface {
protected $providers = [];
protected $sortedProviders;
public function getQuery($id, OperationParams $operation) {
foreach ($this
->getSortedProviders() as $provider) {
if ($query = $provider
->getQuery($id, $operation)) {
return $query;
}
}
return NULL;
}
public function addQueryProvider(QueryProviderInterface $provider, $priority = 0) {
$this->providers[$priority][] = $provider;
$this->sortedProviders = NULL;
}
protected function getSortedProviders() {
if (!isset($this->sortedProviders)) {
krsort($this->providers);
$this->sortedProviders = [];
foreach ($this->providers as $providers) {
$this->sortedProviders = array_merge($this->sortedProviders, $providers);
}
}
return $this->sortedProviders;
}
}