Skip to content
Merged
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
1 change: 1 addition & 0 deletions docs/driver.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ sortFields
When entity types are created, and after the definition event,
the fields will be sorted alphabetically when set to true.
This can aid reading of the documentation created by GraphQL.
The default is false.


useHydratorCache
Expand Down
6 changes: 6 additions & 0 deletions docs/upgrade.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ parameter is named ``$enable``, as the other boolean methods' are.
// 14.0
ConfigBuilder::create()->enableSortFields();

The ``sortFields`` config value is a ``bool``, ``false`` by default. It was
``bool|null``, where ``null``, the default, meant ``false``. Passing
``'sortFields' => null`` to ``Config`` now throws
``ApiSkeletons\Doctrine\ORM\GraphQL\Exception\Configuration``; remove it or
pass ``false``.

A computed field of a method such as ``getaway()``, whose name only begins
with ``get``, is named for the whole method, ``getaway``, rather than ``away``.

Expand Down
3 changes: 2 additions & 1 deletion docs/versions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ ORM versions do not support ``doctrine/persistence`` 4.
collection by its ``#[ORM\OrderBy]`` first
- Configuration: ``globalEnable`` and ``ignoreFields`` are removed; ``globalByValue`` and
``byValue`` are renamed ``extractByValue``; ``ConfigBuilder::sortFields()`` is renamed
``enableSortFields()``; config values are validated
``enableSortFields()``; ``sortFields`` is a ``bool`` and may not be ``null``; config
values are validated
- Types: ``decimal`` is a ``String``; date-times are converted to the default timezone;
the date and time scalars reject impossible and invalid values and serialize only date
objects; filter, connection and input type names change; the ``sort`` filter takes the
Expand Down
16 changes: 8 additions & 8 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ final class Config
protected readonly string|null $entityPrefix;

/**
* @var bool|null When set to true entity fields will be
* sorted alphabetically
* @var bool When set to true entity fields will be
* sorted alphabetically
*/
protected readonly bool|null $sortFields;
protected readonly bool $sortFields;

/**
* @var Filters[] An array of filters to exclude from
Expand Down Expand Up @@ -127,7 +127,7 @@ final class Config
'limit' => ['int'],
'extractByValue' => ['bool', 'null'],
'entityPrefix' => ['string', 'null'],
'sortFields' => ['bool', 'null'],
'sortFields' => ['bool'],
'excludeFilters' => ['array'],
'formatJsonAs' => [JsonFormat::class, 'string'],
'useNonNullTypes' => ['bool'],
Expand All @@ -146,7 +146,7 @@ public function __construct(array $config = [])
'limit' => 1000,
'extractByValue' => null,
'entityPrefix' => null,
'sortFields' => null,
'sortFields' => false,
'excludeFilters' => [],
'formatJsonAs' => JsonFormat::String,
'useNonNullTypes' => false,
Expand Down Expand Up @@ -187,7 +187,7 @@ public function __construct(array $config = [])
*
* @param array<array-key, mixed> $config
*
* @return array{group: string, groupSuffix: string|null, useHydratorCache: bool, useQueryResultCache: bool, batchAssociations: bool, batchLimit: int, limit: int, extractByValue: bool|null, entityPrefix: string|null, sortFields: bool|null, excludeFilters: Filters[], formatJsonAs: JsonFormat, useNonNullTypes: bool}
* @return array{group: string, groupSuffix: string|null, useHydratorCache: bool, useQueryResultCache: bool, batchAssociations: bool, batchLimit: int, limit: int, extractByValue: bool|null, entityPrefix: string|null, sortFields: bool, excludeFilters: Filters[], formatJsonAs: JsonFormat, useNonNullTypes: bool}
*
* @throws ConfigurationException
*/
Expand Down Expand Up @@ -247,7 +247,7 @@ private function validate(array $config): array
);
}

/** @var array{group: string, groupSuffix: string|null, useHydratorCache: bool, useQueryResultCache: bool, batchAssociations: bool, batchLimit: int, limit: int, extractByValue: bool|null, entityPrefix: string|null, sortFields: bool|null, excludeFilters: Filters[], formatJsonAs: JsonFormat, useNonNullTypes: bool} $validated */
/** @var array{group: string, groupSuffix: string|null, useHydratorCache: bool, useQueryResultCache: bool, batchAssociations: bool, batchLimit: int, limit: int, extractByValue: bool|null, entityPrefix: string|null, sortFields: bool, excludeFilters: Filters[], formatJsonAs: JsonFormat, useNonNullTypes: bool} $validated */
$validated = $config;

return $validated;
Expand Down Expand Up @@ -298,7 +298,7 @@ public function getEntityPrefix(): string|null
return $this->entityPrefix;
}

public function getSortFields(): bool|null
public function getSortFields(): bool
{
return $this->sortFields;
}
Expand Down
2 changes: 1 addition & 1 deletion src/ConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ final class ConfigBuilder
private int $limit = 1000;
private bool|null $extractByValue = null;
private string|null $entityPrefix = null;
private bool|null $sortFields = null;
private bool $sortFields = false;
/** @var Filters[] */
private array $excludeFilters = [];

Expand Down
2 changes: 1 addition & 1 deletion test/Feature/ConfigBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function testDefaultValues(): void
$this->assertEquals(1000, $config->getLimit());
$this->assertNull($config->getExtractByValue());
$this->assertNull($config->getEntityPrefix());
$this->assertNull($config->getSortFields());
$this->assertFalse($config->getSortFields());
$this->assertEquals([], $config->getExcludeFilters());
}

Expand Down
4 changes: 4 additions & 0 deletions test/Feature/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public static function invalidValueProvider(): array
['extractByValue' => 1],
'Invalid configuration value for extractByValue: expected bool or null, got int.',
],
'null sortFields' => [
['sortFields' => null],
'Invalid configuration value for sortFields: expected bool, got null.',
],
'excludeFilters not an array' => [
['excludeFilters' => 'eq'],
'Invalid configuration value for excludeFilters: expected array, got string.',
Expand Down
Loading