diff --git a/src/Definition/Type/CustomScalarType.php b/src/Definition/Type/CustomScalarType.php index 1fb09c2cb..e2d3c1034 100644 --- a/src/Definition/Type/CustomScalarType.php +++ b/src/Definition/Type/CustomScalarType.php @@ -32,6 +32,7 @@ class CustomScalarType extends BaseCustomScalarType { /** @phpstan-var CustomScalarConfig */ + // @phpstan-ignore-next-line specialize type public array $config; /** diff --git a/tests/Functional/Command/GraphDumpSchemaCommandTest.php b/tests/Functional/Command/GraphDumpSchemaCommandTest.php index a495068d8..5ace5a3dc 100644 --- a/tests/Functional/Command/GraphDumpSchemaCommandTest.php +++ b/tests/Functional/Command/GraphDumpSchemaCommandTest.php @@ -143,12 +143,41 @@ private function assertCommandExecution(array $input, string $expectedFile, stri if ('json' === $format) { $expected = json_decode($expected, true); $actual = json_decode($actual, true); + $this->removeVersionDependentSchemaEntries($expected); + $this->removeVersionDependentSchemaEntries($actual); $this->sortSchemaEntry($expected, 'types', 'name'); $this->sortSchemaEntry($actual, 'types', 'name'); } $this->assertEqualsCanonicalizing($expected, $actual); } + /** + * Newer versions of webonyx/graphql-php introduce the "@specifiedBy" directive + * and the "__Type.specifiedByURL" field. Strip them so that the fixtures + * stay valid regardless of the installed version. + */ + private function removeVersionDependentSchemaEntries(array &$entries): void + { + $schema = &$entries['data']['__schema']; + if (!isset($schema)) { + $schema = &$entries['__schema']; + } + + $schema['directives'] = array_values(array_filter( + $schema['directives'], + fn (array $directive) => 'specifiedBy' !== $directive['name'] + )); + + foreach ($schema['types'] as &$type) { + if ('__Type' === $type['name']) { + $type['fields'] = array_values(array_filter( + $type['fields'], + fn (array $field) => 'specifiedByURL' !== $field['name'] + )); + } + } + } + private function sortSchemaEntry(array &$entries, string $entryKey, string $sortBy): void { if (isset($entries['data']['__schema'][$entryKey])) {