My mutation scheme:
mutation edit($id: Int!) {
user_edit(id:$id) {
user_name
}
}
query variable is follow
{
"id": 1
}
I use this with laravel-graphql. Here is my definition of user_edit
class UserEdit extends Mutation
{
protected $attributes = [
'name' => 'UserEdit',
'description' => 'A mutation'
];
public function type()
{
return GraphQL::type('UserInfo');
}
public function args()
{
return [
'id' => [
'type' => Type::int(),
],
];
}
public function resolve($root, $args, $context, ResolveInfo $info)
{
var_dump($args);exit;
$data = User::find($args['id']);
return $data;
}
}
I use my query string to request the graphql server, then server return my error
{
"data": null,
"errors": [
{
"message": "Variable \"$edit1\" of required type \"Int!\" was not provided.",
"locations": [
{
"line": 1,
"column": 11
}
]
}
]
}
l tried a lot things and read the document on github [https://github.com/Folkloreatelier/laravel-graphql#creating-a-mutation][1]
and read the document of graphql's website ,and change my args definition style in many ways, but all failed, and Strange is l can get args but use static variable like follow
mutation edit{
user_edit(id:1) {
user_name
}
}
and then it worked! l tried to goole but get nothing about this. l think l really need some help