diff --git a/composer.json b/composer.json index 5d780dd..6669d27 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "homepage": "https://www.drupal.org/project/graphql_search_api", "license": "GPL-2.0+", "require": { - "php": ">=7.2" + "php": ">=8.1" }, "minimum-stability": "dev" } diff --git a/graphql_search_api.info.yml b/graphql_search_api.info.yml index 27548aa..a973bf8 100755 --- a/graphql_search_api.info.yml +++ b/graphql_search_api.info.yml @@ -1,8 +1,7 @@ name: Graphql Search API type: module description: A Search API GraphQL schema. -core: 8.x -core_version_requirement: ^8 || ^9 +core_version_requirement: ^9 || ^10 package: Search dependencies: - graphql diff --git a/src/Plugin/GraphQL/Fields/SearchAPISearch.php b/src/Plugin/GraphQL/Fields/SearchAPISearch.php index fdc45fc..ebdd58d 100644 --- a/src/Plugin/GraphQL/Fields/SearchAPISearch.php +++ b/src/Plugin/GraphQL/Fields/SearchAPISearch.php @@ -103,21 +103,25 @@ public function resolveValues($value, array $args, ResolveContext $context, Reso // Execute search. try { $results = $this->query->execute(); + + // Get search response from results. + $search_response = $this->getSearchResponse($results); + + // Add the result count to the response. + $search_response['result_count'] = $results->getResultCount(); + + // Set response type. + $search_response['type'] = 'SearchAPIResult'; } - // Handle error, check exception type -> SearchApiException ? + // Handle error, check exception type -> SearchApiException ? catch (\Exception $exception) { $this->logger->get('graphql_search_api')->error($exception->getMessage()); + $search_response = [ + 'result_count' => 0, + 'type' => 'SearchAPIResult', + ]; } - // Get search response from results. - $search_response = $this->getSearchResponse($results); - - // Add the result count to the response. - $search_response['result_count'] = $results->getResultCount(); - - // Set response type. - $search_response['type'] = 'SearchAPIResult'; - yield $search_response; }