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

Unexpected input field value causes TypeError #69

Closed
mrix opened this issue Oct 28, 2016 · 1 comment
Closed

Unexpected input field value causes TypeError #69

mrix opened this issue Oct 28, 2016 · 1 comment
Assignees
Labels

Comments

@mrix
Copy link

mrix commented Oct 28, 2016

Hi. I have this code in the userEdit field:

/**
 * @inheritdoc
 */
public function getName()
{
    return 'userEdit';
}
/**
 * @inheritdoc
 */
public function getType()
{
    return new UserType();
}
/**
 * @inheritdoc
 */
public function build(FieldConfig $config)
{
    $this->addArgument(
        new InputField([
            'name' => 'id',
            'type' => new NonNullType(new IntType()),
        ])
    )->addArgument(
        new InputField([
            'name' => 'data',
            'type' => new NonNullType(new InputObjectType([
                'name' => 'data',
                'fields' => [
                    [
                        'name' => 'fullName',
                        'type' => new NonNullType(new StringType()),
                    ],
                ],
            ])),
        ])
    );
    parent::build($config);
}

and the command:

mutation m {
  userEdit(id: 1000000, data: 0) {
    fullName
  }
}

returns:

{
  "errors": {
    "message": "Type error: Argument 1 passed to Youshido\\GraphQL\\Validator\\ResolveValidator\\ResolveValidator::processInputObject() must be an instance of Youshido\\GraphQL\\Parser\\Ast\\ArgumentValue\\InputObject, instance of Youshido\\GraphQL\\Parser\\Ast\\ArgumentValue\\Literal given, called in /var/www/symfony/vendor/youshido/graphql/src/Validator/ResolveValidator/ResolveValidator.php on line 101"
  }
}

Any unexpected value ([], 0, "str") for the data argument is not validated and causes to TypeError.

Also this request for the same schema:

mutation m {
  userEdit(id: 1000000, data: {unknownField: "a"}) {
    fullName
  }
}

returns only [] without any errors/exceptions.

@portey portey self-assigned this Oct 28, 2016
@portey portey added the bug label Oct 28, 2016
@portey
Copy link
Contributor

portey commented Nov 11, 2016

@mrix, thank's for you interesting. We've already fixed it in last release.

@portey portey closed this as completed Nov 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants