From 44b692d212edf20de304c87b378033220770f9d9 Mon Sep 17 00:00:00 2001 From: MAVRI Matina Date: Thu, 6 Jun 2024 12:06:11 +0200 Subject: [PATCH 1/2] Fix undefined variable results --- src/Plugin/GraphQL/Fields/SearchAPISearch.php | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) 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; } From b771f46f2de7d0d1d5e4e80b7b176b1633fc600c Mon Sep 17 00:00:00 2001 From: MAVRI Matina Date: Tue, 8 Oct 2024 11:15:06 +0200 Subject: [PATCH 2/2] Issue #57: Drupal 10 compatibility --- composer.json | 2 +- graphql_search_api.info.yml | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) 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