Open sustmi opened 11 months ago
Let's say I have the following Input object:
HeroInput: type: input-object config: fields: firstname: type: "String!" lastname: type: "String!"
and a resolver using this as an input:
Query: type: object config: fields: heroes: type: "Hero" args: name: type: "HeroInput!" resolve: "@=query('heroes', args['name'])"
The resolver method in PHP gets the name input as an array containing firstname and lastname keys.
name
firstname
lastname
public function heroes(array $name) { var_dump($name['firstname'], $name['lastname']);
I would like to have the input object as a real object in my resolver:
public function heroes(HeroInput $name) {
Documentation of webonyx/graphql-php mentions parseValue configuration: https://webonyx.github.io/graphql-php/type-definitions/inputs/#converting-input-object-array-to-value-object that could be used for this conversion.
webonyx/graphql-php
parseValue
However, when I try to use parseValue for input-object:
input-object
HeroInput: type: input-object config: fields: firstname: type: "String!" lastname: type: "String!" parseValue: ['HeroInput', 'parseValue']
type I get error:
PHP Fatal error: Uncaught Symfony\Component\Config\Definition\Exception\InvalidConfigurationException: Unrecognized option "parseValue" under "overblog_graphql_types.HeroInput._input_object_config". Available options are "description", "fields", "name", "validation".
So it seems that the parseValue from webonyx/graphql-php is not exposed by overblog/graphql-bundle for input-object. Note: The custom-scalar type supports the parseValue configuration: https://github.com/overblog/GraphQLBundle/blob/master/docs/definitions/type-system/scalars.md#with-yaml .
overblog/graphql-bundle
custom-scalar
It would be nice to have the option available so that resolver method could get directly the PHP object instead of a plain array.
Let's say I have the following Input object:
and a resolver using this as an input:
The resolver method in PHP gets the
name
input as an array containingfirstname
andlastname
keys.I would like to have the input object as a real object in my resolver:
Documentation of
webonyx/graphql-php
mentionsparseValue
configuration: https://webonyx.github.io/graphql-php/type-definitions/inputs/#converting-input-object-array-to-value-object that could be used for this conversion.However, when I try to use
parseValue
forinput-object
:type I get error:
So it seems that the
parseValue
fromwebonyx/graphql-php
is not exposed byoverblog/graphql-bundle
forinput-object
. Note: Thecustom-scalar
type supports theparseValue
configuration: https://github.com/overblog/GraphQLBundle/blob/master/docs/definitions/type-system/scalars.md#with-yaml .It would be nice to have the option available so that resolver method could get directly the PHP object instead of a plain array.