Skip to content

Commit

Permalink
Add partial property
Browse files Browse the repository at this point in the history
  • Loading branch information
ruudk committed Nov 13, 2024
1 parent 14c4bd2 commit bd3c5d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/GraphQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,15 @@ public static function getStandardTypes(): array
* Standard types not listed here remain untouched.
*
* @param array<string, ScalarType> $types
*
* @api
* @param bool $partial Whether to replace only types listed in $types or all standard types
*
* @throws InvariantViolation
*@api
*
*/
public static function overrideStandardTypes(array $types): void
public static function overrideStandardTypes(array $types, bool $partial = true): void
{
Type::overrideStandardTypes($types);
Type::overrideStandardTypes($types, $partial);
}

/**
Expand Down
7 changes: 6 additions & 1 deletion src/Type/Definition/Type.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,18 @@ public static function getStandardTypes(): array

/**
* @param array<ScalarType> $types
* @param bool $partial Whether to replace only types listed in $types or all standard types
*
* @throws InvariantViolation
*/
public static function overrideStandardTypes(array $types): void
public static function overrideStandardTypes(array $types, bool $partial = true): void
{
self::reset();

if (! $partial) {
static::$standardTypes = null;
}

foreach ($types as $type) {
// @phpstan-ignore-next-line generic type is not enforced by PHP
if (! $type instanceof ScalarType) {
Expand Down

0 comments on commit bd3c5d4

Please sign in to comment.