Skip to content

Commit 7cd7412

Browse files
committed
Update changelog and improve test case
1 parent 0e3645a commit 7cd7412

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ You can find and compare releases at the [GitHub release page](https://github.co
4141
- Add validation rule `UniqueEnumValueNames`
4242
- Add SDL validation rule `UniqueOperationTypes` (#995)
4343
- Add ability to remove custom validation rules after adding them via `DocumentValidator::removeRule()`
44+
- Allow lazy enum values
4445

4546
### Optimized
4647

tests/Type/EnumTypeTest.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,10 +685,16 @@ public function testLazilyDefineValuesAsCallable(): void
685685

686686
$schema = new Schema(['query' => $QueryType]);
687687

688+
self::assertSame(0, $called, 'Should not eagerly call enum values during schema construction');
689+
690+
$query = '{ colorEnum(fromEnum: RED) }';
688691
self::assertEquals(
689692
['data' => ['colorEnum' => 'RED']],
690-
GraphQL::executeQuery($schema, '{ colorEnum(fromEnum: RED) }')->toArray()
693+
GraphQL::executeQuery($schema, $query)->toArray()
691694
);
692-
self::assertSame(1, $called);
695+
GraphQL::executeQuery($schema, $query);
696+
697+
// @phpstan-ignore-next-line $called is mutated
698+
self::assertSame(1, $called, 'Should call enum values callable exactly once');
693699
}
694700
}

0 commit comments

Comments
 (0)