Skip to content
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 .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ jobs:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/coding-standards.yml@1.3.0"
with:
php-version: '8.1'
php-version: '8.3'
composer-options: '--prefer-dist --ignore-platform-req=php'

3 changes: 1 addition & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ jobs:
fail-fast: false
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
dependencies:
- "highest"
- "lowest"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
php-version: '8.3'

- uses: actions/checkout@v2

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ Each field has their own set of filters. Based on the field type, some or all o
* startwith - A like query with a wildcard on the right side of the value.
* endswith - A like query with a wildcard on the left side of the value.
* contains - A like query.
* sort & sortPriority - Sort the results by a field. Use sortPriority to sort by multiple fields.

You may [exclude any filter](https://doctrine-orm-graphql.apiskeletons.dev/en/latest/attributes.html#entity) from any entity, association, or globally.

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
}
],
"require": {
"php": "^8.1",
"doctrine/orm": "^2.18 || ^3.0",
"php": "^8.3",
"doctrine/orm": "^3.0",
"doctrine/doctrine-laminas-hydrator": "^3.2",
"webonyx/graphql-php": "^v15.0",
"psr/container": "^1.1 || ^2.0",
"psr/container": "^2.0",
"league/event": "^3.0"
},
"require-dev": {
"doctrine/coding-standard": "^11.0 || ^12.0",
"doctrine/coding-standard": "^13.0",
"doctrine/dbal": "^3.1 || ^4.0",
"phpunit/phpunit": "^9.6",
"vimeo/psalm": "^5.4",
"vimeo/psalm": "^6.13",
"symfony/cache": "^5.3||^6.2",
"php-parallel-lint/php-parallel-lint": "^1.3.2",
"phpstan/phpstan": "^1.12 || ^2.0"
Expand Down
2 changes: 1 addition & 1 deletion docs/driver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Creating a Driver with all config options
use ApiSkeletons\Doctrine\ORM\GraphQL\Driver;
use ApiSkeletons\Doctrine\ORM\GraphQL\Filter\Filters;

$driver = new Driver($entityManager, new Config[
$driver = new Driver($entityManager, new Config([
'entityPrefix' => 'App\\ORM\\Entity\\',
'group' => 'customGroup',
'groupSuffix' => 'customGroupSuffix',
Expand Down
31 changes: 16 additions & 15 deletions docs/queries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,21 @@ specific to the entity they filter upon.

Provided Filters::

eq - Equals; same as name: value. DateTime not supported. See Between.
neq - Not Equals
gt - Greater Than
lt - Less Than
gte - Greater Than or Equal To
lte - Less Than or Equal To
in - Filter for values in an array
notin - Filter for values not in an array
between - Filter between `from` and `to` values. Good substitute for DateTime Equals.
contains - Strings only. Similar to a Like query as `like '%value%'`
startswith - Strings only. A like query from the beginning of the value `like 'value%'`
endswith - Strings only. A like query from the end of the value `like '%value'`
isnull - If `true` return results where the field is null.
sort - Sort the result by this field. Value is 'asc' or 'desc'
eq - Equals; same as name: value. DateTime not supported. See Between.
neq - Not Equals
gt - Greater Than
lt - Less Than
gte - Greater Than or Equal To
lte - Less Than or Equal To
in - Filter for values in an array
notin - Filter for values not in an array
between - Filter between `from` and `to` values. Good substitute for DateTime Equals.
contains - Strings only. Similar to a Like query as `like '%value%'`
startswith - Strings only. A like query from the beginning of the value `like 'value%'`
endswith - Strings only. A like query from the end of the value `like '%value'`
isnull - If `true` return results where the field is null.
sort - Sort the result by this field. Value is 'asc' or 'desc'
sortPriority - Sort priority when multiple sort fields are used. Value is an integer starting at 1.

The format for using these filters is:

Expand Down Expand Up @@ -153,7 +154,7 @@ A complete query for all pagination data:
}

Cursors are included with each edge. A cursor is a base64 encoded
offset from the beginning of the result set. ``base64_encode('0');`` is
offset from the beginning of the result set. ``base64_encode('0');`` is
``MA==`` to use when creating a paginated query.


Expand Down
3 changes: 3 additions & 0 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Closure;
use GraphQL\Error\Error;
use Override;
use Psr\Container\ContainerInterface;
use ReflectionClass;
use ReflectionException;
Expand All @@ -21,12 +22,14 @@ abstract class Container implements ContainerInterface
/** @var mixed[] */
protected array $register = [];

#[Override]
public function has(string $id): bool
{
return isset($this->register[strtolower($id)]);
}

/** @throws Error */
#[Override]
public function get(string $id): mixed
{
$id = strtolower($id);
Expand Down
2 changes: 2 additions & 0 deletions src/Event/Criteria.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Doctrine\ORM\PersistentCollection;
use GraphQL\Type\Definition\ResolveInfo;
use League\Event\HasEventName;
use Override;

/**
* This event is dispatched when a Doctrine Criteria is created.
Expand All @@ -34,6 +35,7 @@ public function __construct(
) {
}

#[Override]
public function eventName(): string
{
return $this->eventName;
Expand Down
2 changes: 2 additions & 0 deletions src/Event/EntityDefinition.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use ArrayObject;
use League\Event\HasEventName;
use Override;

/**
* This event is fired each time an entity GraphQL type is created
Expand All @@ -20,6 +21,7 @@ public function __construct(
) {
}

#[Override]
public function eventName(): string
{
return $this->eventName;
Expand Down
2 changes: 2 additions & 0 deletions src/Event/Metadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use ArrayObject;
use League\Event\HasEventName;
use Override;

/**
* This event is fired when the metadta is created
Expand All @@ -19,6 +20,7 @@ public function __construct(
) {
}

#[Override]
public function eventName(): string
{
return $this->eventName;
Expand Down
2 changes: 2 additions & 0 deletions src/Event/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\ORM\QueryBuilder as DoctrineQueryBuilder;
use GraphQL\Type\Definition\ResolveInfo;
use League\Event\HasEventName;
use Override;

/**
* This event is fired when the QueryBuilder is created for an entity
Expand All @@ -27,6 +28,7 @@ public function __construct(
) {
}

#[Override]
public function eventName(): string
{
return $this->eventName;
Expand Down
87 changes: 45 additions & 42 deletions src/Filter/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,43 @@
*/
enum Filters: string
{
case EQ = 'eq';
case NEQ = 'neq';
case LT = 'lt';
case LTE = 'lte';
case GT = 'gt';
case GTE = 'gte';
case BETWEEN = 'between';
case CONTAINS = 'contains';
case STARTSWITH = 'startswith';
case ENDSWITH = 'endswith';
case IN = 'in';
case NOTIN = 'notin';
case ISNULL = 'isnull';
case SORT = 'sort';
case EQ = 'eq';
case NEQ = 'neq';
case LT = 'lt';
case LTE = 'lte';
case GT = 'gt';
case GTE = 'gte';
case BETWEEN = 'between';
case CONTAINS = 'contains';
case STARTSWITH = 'startswith';
case ENDSWITH = 'endswith';
case IN = 'in';
case NOTIN = 'notin';
case ISNULL = 'isnull';
case SORT = 'sort';
case SORTPRIORITY = 'sortPriority';

/**
* Fetch the description for the filter
*/
public function description(): string
{
return match ($this) {
self::EQ => 'Equals',
self::NEQ => 'Not equals',
self::LT => 'Less than',
self::LTE => 'Less than or equals',
self::GT => 'Greater than',
self::GTE => 'Greater than or equals',
self::BETWEEN => 'Is between from and to inclusive of from and to',
self::CONTAINS => 'Contains the value. Strings only.',
self::STARTSWITH => 'Starts with the value. Strings only.',
self::ENDSWITH => 'Ends with the value. Strings only.',
self::IN => 'In the array of values',
self::NOTIN => 'Not in the array of values',
self::ISNULL => 'Is null',
self::SORT => 'Sort by field. ASC or DESC.',
self::EQ => 'Equals',
self::NEQ => 'Not equals',
self::LT => 'Less than',
self::LTE => 'Less than or equals',
self::GT => 'Greater than',
self::GTE => 'Greater than or equals',
self::BETWEEN => 'Is between from and to inclusive of from and to',
self::CONTAINS => 'Contains the value. Strings only.',
self::STARTSWITH => 'Starts with the value. Strings only.',
self::ENDSWITH => 'Ends with the value. Strings only.',
self::IN => 'In the array of values',
self::NOTIN => 'Not in the array of values',
self::ISNULL => 'Is null',
self::SORT => 'Sort by field. ASC or DESC.',
self::SORTPRIORITY => 'Specify the sort priority of a field. Priorities are sorted lowest number first. Sort must also be speciifed.',
};
}

Expand All @@ -61,20 +63,21 @@ public function description(): string
public function type(ScalarType|ListOfType $type): Type
{
return match ($this) {
self::EQ => $type,
self::NEQ => $type,
self::LT => $type,
self::LTE => $type,
self::GT => $type,
self::GTE => $type,
self::BETWEEN => new Between($type),
self::CONTAINS => $type,
self::STARTSWITH => $type,
self::ENDSWITH => $type,
self::IN => Type::listOf($type),
self::NOTIN => Type::listOf($type),
self::ISNULL => Type::boolean(),
self::SORT => Type::string(),
self::EQ => $type,
self::NEQ => $type,
self::LT => $type,
self::LTE => $type,
self::GT => $type,
self::GTE => $type,
self::BETWEEN => new Between($type),
self::CONTAINS => $type,
self::STARTSWITH => $type,
self::ENDSWITH => $type,
self::IN => Type::listOf($type),
self::NOTIN => Type::listOf($type),
self::ISNULL => Type::boolean(),
self::SORT => Type::string(),
self::SORTPRIORITY => Type::int(),
};
}

Expand Down
Loading
Loading