sailor
sailor copied to clipboard
Cannot use "Properties" as Input Member
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
- Have a input type with a member named 'properties'
input CreateItem {
foo: String!
properties: [String]!
bar: String!
}
- Run vendor/bin/sailor to generate the PhpClasses
- Instantiate the object with the properties member set
$input = CreateItemInput::make(
foo: 'a',
properties: [
'hello'
],
bar : 'b'
);
- 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.