Skip to content

Fix undefined variable results #56

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

Open
wants to merge 3 commits into
base: 8.x-1.x
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
3 changes: 1 addition & 2 deletions graphql_search_api.info.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
24 changes: 14 additions & 10 deletions src/Plugin/GraphQL/Fields/SearchAPISearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
Expand Down