-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Description
I've started using this library recently and love it so far, I have a small support request though. :-)
Currently, I have a mutation that allows a user to create a Company.
'createCompany' => [
'type' => Type::nonNull($types->get(Company::class)),
'args' => [
'input' => Type::nonNull($types->getInput(Company::class)),
],
'resolve' => function ($root, $args) use ($resolver) {
return $resolver->createObject(Company::class, $args['input']);
},
],
The Company model holds a Collection (Doctrine) of objects of the Entity Contact. Retrieving the Collection through GraphQL is not a problem:
/**
* @return \Doctrine\Common\Collections\Collection
* @\GraphQL\Doctrine\Annotation\Field(type="?Contact[]")
*/
public function getContacts() : Collection
{
return $this->contacts;
}
I have annotated Company::getContacts() using the Field annotation as per the documentation (this works, but am I doing this the right way?).
Setting the collection however, does not work. This code:
/**
* @param \Doctrine\Common\Collections\Collection $contacts
* @\GraphQL\Doctrine\Annotation\Input(type="Contact[]")
*/
public function setContacts(Collection $contacts)
{
$this->contacts = $contacts;
}
Results in this error:
Type for parameter `$contacts` for method `Company::setContacts()` must be an instance of `GraphQL\\Type\\Definition\\InputType`, but was `GraphQL\\Type\\Definition\\ObjectType`. Use `@API\\Input` annotation to specify a custom InputType.
What am I doing wrong?
Thanks in advance!
PS: I'm using ecodev/graphql-doctrine:2.0.1 and webonyx/graphql-php:v0.11.6.