Type resolvers are not called on mutation results?
brunoreis opened this issue · 0 comments
brunoreis commented
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?