-
-
Notifications
You must be signed in to change notification settings - Fork 571
Closed
Description
I'm using the laravel-graphql, and created an issue but I'm not sure if it's something that should actually be created here (still trying to wrap my head around GraphQL).
When working with Relay, it expects that mutations have only one argument called input. Looking at the todo example, in the schema.json file it has that field listed as an INPUT_OBJECT type. I created the following (again, using laravel-graphql), but I'm unable to get the fields from the InputObjectType. Am I doing something wrong?
namespace App\GraphQL\Mutations;
use GraphQL;
use App\Models\Customer;
use GraphQL\Type\Definition\Type;
use GraphQL\Type\Definition\InputObjectType;
use Folklore\GraphQL\Support\Mutation;
class UpdateCustomerEmail extends Mutation
{
/**
* Associated GraphQL Type.
*
* @return mixed
*/
public function type()
{
return GraphQL::type('customerPayload');
}
/**
* Available arguments for mutation.
*
* @return array
*/
public function args()
{
return [
'input' => [
'name' => 'input',
'type' => new InputObjectType([
'name' => 'updateCustomerEmailInput',
'fields' => [
'entity_id' => [
'name' => 'entity_id',
'type' => Type::nonNull(Type::string())
],
'email' => [
'name' => 'email',
'type' => Type::nonNull(Type::string())
]
]
])
]
];
}
/**
* Resolve mutation.
*
* @param string $root
* @param array $args
* @return Customer
*/
public function resolve($root, $args, $info)
{
// $root is null, $args is an empty array and nothing in $info gives me the
// variables passed in the request
$customer = Customer::find($args['input']['entity_id']); // $args['input'] is not set
$customer->email = $args['input']['email'];
return $customer;
}
}
Metadata
Metadata
Assignees
Labels
No labels