sailor icon indicating copy to clipboard operation
sailor copied to clipboard

Cannot use "Properties" as Input Member

Open tobidotYD opened this issue 4 months ago • 1 comments

Describe the bug

An graphql argument named 'properties' is colliding with the protected member of the Base class "ObjectLike". It will result in resetting all arguments coming before 'properties' resulting in an invalid state of that object.

Expected behavior/Solution

"properties" should be a possible as an argument for a graphql input type.

Currently i am bypassing the issue by building the Object manually instead of using the 'make'.

$input = new CreateItemInput();
$input->foo = 'a';
$input->properties = [ 'hello' ];
$input->bar = 'b';

Maybe this could be handled like a php keyword and prefixed with an '_'?

Steps to reproduce

  1. Have a input type with a member named 'properties'
input CreateItem {
   foo: String!
   properties: [String]!
   bar: String!
}
  1. Run vendor/bin/sailor to generate the PhpClasses
  2. Instantiate the object with the properties member set
$input = CreateItemInput::make(
   foo: 'a',
   properties: [
     'hello'
   ],
   bar : 'b'
);
  1. Unfolding the object now yields an error even with correct input $input->toStdClass()

Output/Logs

Argument #1 ($foo) must be of type string, int given, called in vendor/spawnia/sailor/src/ObjectLike.php on line 74.

tobidotYD avatar Jun 04 '25 12:06 tobidotYD