Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for parseValue configuration for input-object types #1147

Open
sustmi opened this issue Dec 11, 2023 · 0 comments
Open

Add support for parseValue configuration for input-object types #1147

sustmi opened this issue Dec 11, 2023 · 0 comments

Comments

@sustmi
Copy link

sustmi commented Dec 11, 2023

Q A
Bug report? no
Feature request? yes
BC Break report? no
RFC? no
Version/Branch master

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.

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.

However, when I try to use parseValue for 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 .

It would be nice to have the option available so that resolver method could get directly the PHP object instead of a plain array.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant