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

Type resolvers are not called on mutation results? #25

Open
brunoreis opened this issue Mar 3, 2017 · 0 comments
Open

Type resolvers are not called on mutation results? #25

brunoreis opened this issue Mar 3, 2017 · 0 comments

Comments

@brunoreis
Copy link

I have this query:

mutation{
    registerThread(message_ids:[302]){
        thread {
            id
        }
        messagesStatus{
            cleanMessagesCount
        }
    }
}

This is the RegisterThreadField definition:

class RegisterThreadField extends AbstractContainerAwareField
{
    /**
     * @return ThreadType
     */
    public function getType()
    {
        return new ObjectType([
            'name'   => 'RegisterThreadMutationType',
            'fields' => [
                'thread' => [
                    'type' => new ThreadType()
                ],
                'messagesStatus' => [
                    'type' => new MessagesStatusType()
                ]
            ]
        ]);
    }

    public function build(FieldConfig $config)
    {
        $config->addArguments([
            'message_ids' => new ListType(
                new IdType()
            )
         ]);
    }

    public function resolve($value, array $args, ResolveInfo $info)
    {
        return $this->container
            ->get('app.resolver.register_thread')
            ->resolve(new ParameterBag($args));
    }

And this is the MessagesStatusType

class MessagesStatusType extends AbstractObjectType
{
    /**
     * @param \Youshido\GraphQL\Config\Object\ObjectTypeConfig $config
     */
    public function build($config)
    {
        $config->addFields([
            'id' => new IdType(),
            'oldestMessageDate' => [
                'type'    => new DateTimeType(),
                'resolve' => ['@app.resolver.messages_status','oldestMessageDate']
            ],
            'newestMessageDate' => [
                'type'    => new DateTimeType(),
                'resolve' => ['@app.resolver.messages_status','newestMessageDate']
            ],
            'messagesCount' => [
                'type'    => new IntType(),
                'resolve' => ['@app.resolver.messages_status','messagesCount']
            ],
            'cleanMessagesCount' => [
                'type'    => new IntType(),
                'resolve' => ['@app.resolver.messages_status','cleanMessagesCount']
            ]
        ]);
    }

The resolver result does not return an index for the messagesStatus field of the query. But, I was expecting that the custom resolvers defined on the MessagesStatusType would take care of that. But it seem that they are not being called.

This is the result:

{
    "data": {
        "registerThread": {
            "thread": {
                "id": "43"
            },
            "messagesStatus": null
        }
    }
}

Should those resolvers (declared as callable services) on the MessagesStatusType class have being called?

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