Update RenameArgsDirective.php#2763
Conversation
|
Bug: @rename directive drops field when attribute name matches the original field name Problem When using @rename(attribute: "currency") on a field already named currency (i.e., source name === target name), the field is silently dropped from the arguments and never reaches the resolver. Example schema: Sending { currency: "USD", settlementDays: 0 } results in the resolver receiving only { settlement_days: 0 } — currency is missing. Root Cause In RenameArgsDirective::rename() (line 64-67): if ($maybeRenameDirective instanceof RenameDirective) { When $name === $maybeRenameDirective->attributeArgValue() (e.g., both are "currency"):
Fix if ($maybeRenameDirective instanceof RenameDirective) { Skip the unset when source and target names are identical. Reproduction Schemainput TestInput { Querymutation { Resolver receives: { "first_name": "Jane" }Expected: { "name": "John", "first_name": "Jane" } |
|
Let's throw a DefinitionException instead for that case - the correct fix is to delete the directive. That can be done at schema build time, so it costs nothing at runtime. |
Changes
Breaking changes