Skip to content

Commit 16328bc

Browse files
authored
Adding highly flexible entity query filtering and sorting. (#505)
1 parent 3f10a44 commit 16328bc

27 files changed

Lines changed: 340 additions & 169 deletions

modules/graphql_core/src/Plugin/Deriver/Fields/EntityQueryDeriver.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,6 @@ public function getDerivativeDefinitions($basePluginDefinition) {
6262
'entity_type' => $id,
6363
] + $basePluginDefinition;
6464

65-
/** @var \Drupal\Core\Entity\TypedData\EntityDataDefinitionInterface $definition */
66-
$definition = $this->typedDataManager->createDataDefinition("entity:$id");
67-
$properties = $definition->getPropertyDefinitions();
68-
69-
$queryableProperties = array_filter($properties, function ($property) {
70-
return $property instanceof BaseFieldDefinition && $property->isQueryable();
71-
});
72-
73-
if (!empty($queryableProperties)) {
74-
$derivative['arguments']['filter'] = [
75-
'type' => StringHelper::camelCase($id, 'query', 'filter', 'input'),
76-
];
77-
}
78-
7965
$this->derivatives[$id] = $derivative;
8066
}
8167
}

modules/graphql_core/src/Plugin/Deriver/InputTypes/EntityQueryFilterInputDeriver.php

Lines changed: 0 additions & 108 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Drupal\graphql_core\Plugin\GraphQL\Enums\Common;
4+
5+
use Drupal\graphql\Plugin\GraphQL\Enums\EnumPluginBase;
6+
7+
/**
8+
* @GraphQLEnum(
9+
* id = "query_conjunction",
10+
* name = "QueryConjunction",
11+
* values = {
12+
* "AND" = "AND",
13+
* "OR" = "OR"
14+
* }
15+
* )
16+
*/
17+
class QueryConjunction extends EnumPluginBase {
18+
19+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Drupal\graphql_core\Plugin\GraphQL\Enums\Common;
4+
5+
use Drupal\graphql\Plugin\GraphQL\Enums\EnumPluginBase;
6+
7+
/**
8+
* @GraphQLEnum(
9+
* id = "query_operator",
10+
* name = "QueryOperator",
11+
* values = {
12+
* "=" = "EQUAL",
13+
* "<>" = "NOT_EQUAL",
14+
* "<" = "SMALLER_THAN",
15+
* "<=" = "SMALLER_THAN_OR_EQUAL",
16+
* ">" = "GREATER_THAN",
17+
* ">=" = "GREATER_THAN_OR_EQUAL",
18+
* "IN" = "IN",
19+
* "NOT IN" = "NOT_IN",
20+
* "LIKE" = "LIKE",
21+
* "NOT LIKE" = "NOT_LIKE",
22+
* "BETWEEN" = "BETWEEN",
23+
* "NOT BETWEEN" = "NOT_BETWEEN",
24+
* "IS NULL" = "IS_NULL",
25+
* "IS NOT NULL" = "IS_NOT_NULL"
26+
* }
27+
* )
28+
*/
29+
class QueryOperator extends EnumPluginBase {
30+
31+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace Drupal\graphql_core\Plugin\GraphQL\Enums\Common;
4+
5+
use Drupal\graphql\Plugin\GraphQL\Enums\EnumPluginBase;
6+
7+
/**
8+
* @GraphQLEnum(
9+
* id = "sort_order",
10+
* name = "SortOrder",
11+
* values = {
12+
* "ASC" = "ASC",
13+
* "DESC" = "DESC"
14+
* }
15+
* )
16+
*/
17+
class SortOrder extends EnumPluginBase {
18+
19+
}

0 commit comments

Comments
 (0)