diff --git a/src/Utils/SchemaPrinter.php b/src/Utils/SchemaPrinter.php index a75e12716..0a5f2304b 100644 --- a/src/Utils/SchemaPrinter.php +++ b/src/Utils/SchemaPrinter.php @@ -338,7 +338,7 @@ protected static function printArgs(array $options, array $args, string $indenta */ protected static function printInputValue($arg): string { - $argDecl = "{$arg->name}: {$arg->getType()->toString()}" . static::printDeprecated($arg); + $argDecl = "{$arg->name}: {$arg->getType()->toString()}"; if ($arg->defaultValueExists()) { $defaultValueAST = AST::astFromValue($arg->defaultValue, $arg->getType()); @@ -351,6 +351,8 @@ protected static function printInputValue($arg): string $argDecl .= ' = ' . Printer::doPrint($defaultValueAST); } + $argDecl .= static::printDeprecated($arg); + return $argDecl; } diff --git a/tests/Utils/SchemaPrinterTest.php b/tests/Utils/SchemaPrinterTest.php index 1f383cfe7..797157539 100644 --- a/tests/Utils/SchemaPrinterTest.php +++ b/tests/Utils/SchemaPrinterTest.php @@ -1369,4 +1369,27 @@ interface FooInterface { ['sortArguments' => true] ); } + + public function testPrintDeprecatedFieldArg(): void + { + $schema = $this->buildSingleFieldSchema([ + 'type' => Type::int(), + 'args' => [ + 'id' => [ + 'type' => Type::id(), + 'defaultValue' => '123', + 'deprecationReason' => 'this is deprecated', + ], + ], + ]); + self::assertPrintedSchemaEquals( + <<