Skip to content

Conversation

pavlosdan
Copy link
Contributor

@pavlosdan pavlosdan changed the title allow entity query conditions to be skipped allow entity query conditions to be disabled Apr 16, 2018
@codecov
Copy link

codecov bot commented Apr 16, 2018

Codecov Report

Merging #577 into 8.x-3.x will decrease coverage by 0.05%.
The diff coverage is 55.55%.

Impacted file tree graph

@@             Coverage Diff             @@
##           8.x-3.x     #577      +/-   ##
===========================================
- Coverage    80.79%   80.74%   -0.06%     
===========================================
  Files          186      186              
  Lines         2854     2861       +7     
===========================================
+ Hits          2306     2310       +4     
- Misses         548      551       +3
Impacted Files Coverage Δ
.../Plugin/GraphQL/Fields/EntityQuery/EntityQuery.php 76.41% <55.55%> (-1.37%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 656514f...d4ff7b7. Read the comment docs.

@@ -297,6 +301,13 @@ protected function buildFilterConditions(QueryInterface $query, array $filter) {
// Apply filter conditions.
$conditions = !empty($filter['conditions']) ? $filter['conditions'] : [];
foreach ($conditions as $condition) {
// Set the condition to enabled by default.
$enabled = (isset($condition['enabled'])) ? $condition['enabled'] : true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We support "default" values in the annotation. I think it would be better to use that:

"enabled" =  {
   "default"  = TRUE
   "type" = "Boolean"
}

@@ -270,7 +270,11 @@ protected function applySort(QueryInterface $query, $sort) {
*/
protected function applyFilter(QueryInterface $query, $filter) {
if (!empty($filter) && is_array($filter)) {
$query->condition($this->buildFilterConditions($query, $filter));
//Conditions can be disabled. Check we are not adding an empty condition group.
$filter_conditions = $this->buildFilterConditions($query, $filter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use camelCase in our code ($filterConditions)

@fubhy
Copy link
Contributor

fubhy commented Apr 19, 2018

Thanks!

@fubhy fubhy merged commit 7496af6 into drupal-graphql:8.x-3.x Apr 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants