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

NonNullType not casting to string in query #80

Closed
webmozart opened this issue Nov 8, 2016 · 3 comments
Closed

NonNullType not casting to string in query #80

webmozart opened this issue Nov 8, 2016 · 3 comments
Assignees
Milestone

Comments

@webmozart
Copy link

I'm using NonNullType in my return type like this:

class PersonType extends AbstractObjectType
{
    /**
     * @param ObjectTypeConfig $config
     *
     * @return mixed
     */
    public function build($config)
    {
        $config->addFields([
            'id' => new NonNullType(new IdType()),
            'firstName' => new NonNullType(new StringType()),
            'lastName' => new NonNullType(new StringType()),
        ]);
    }
}

The IDs of my persons are UUIDs. With the code like this, the result is:

{
    "data": {
        "persons": [
            {
                "id": {},
                "firstName": "Bernhard",
                "lastName": "Schussek"
            }
        ]
    }
}

As you can see, the UUID is not cast to a string, but converted to {}. However if I remove the NonNullType around IdType, the result is as expected:

{
    "data": {
        "persons": [
            {
                "id": "6cfb044c-9c0a-4ddd-9ef8-a0b940818db3",
                "firstName": "Bernhard",
                "lastName": "Schussek"
            }
        ]
    }
}
@viniychuk
Copy link
Member

@webmozart is your UUID an object that has __toString method or is it a plain string? Trying to reproduce your case and even though it works with the latest version, I cannot achieve the same results with the old one...

@viniychuk
Copy link
Member

viniychuk commented Nov 8, 2016

@webmozart got it, it didn't work with objects, will work in tonights release – v1.4

@viniychuk viniychuk added this to the v1.4 milestone Nov 8, 2016
@viniychuk viniychuk self-assigned this Nov 9, 2016
viniychuk added a commit that referenced this issue Nov 9, 2016
@viniychuk
Copy link
Member

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

2 participants