Question
oskalo opened this issue · 0 comments
oskalo commented
Hi gays, I'm stuck with arguments processing. How can I process arguments for simple types?
Type example.
class ProductType extends AbstractObjectType
{
public function build($config)
{
$config->addFields([
'id' => new NonNullType(new IdType()),
'category_id' => new IdType(),
'title' => new StringType(),
'slug' => new StringType(),
'picture' => new StringType(),
'description' => new StringType(),
'price' => [
'type' => new StringType(),
'args' => [
'from' => new IntType(),
'to' => new IntType(),
],
'resolve' => function ($from = null, $to = null) {
return $from * $to;
}
],
]);
}
}
I create my custom type and I want get arguments from each field to my resolve method of my ProductField class
class ProductField extends AbstractContainerAwareField
{
public function build(FieldConfig $config)
{
parent::build($config);
$config->addArguments([
'limit' => new IntType(),
'skip' => new IntType()
]);
}
public function resolve($value, array $args, ResolveInfo $info)
{
return $this->container->get('resolver.product')->findAll($args);
}
public function getType()
{
return new ListType(new ProductType());
}
}
Right now I can process only arguments for all object, "limit" and "skip" for object "product", but I very want to get "from" and "to" arguments in "resolve" method too.