I'm using GraphQL in Laravel and I'm encountering this issue:
I've set id
type to string but when I get my query through GraphQL, I get 553366
instead of 0553366c-6ebe-4340-8929-419ad46f4d15
.
Here is my type definition:
public function fields(): array
{
return [
'id' => [
'type' => Type::string()
],
'name_en' => [
'type' => Type::string()
],
'name_fa' => [
'type' => Type::string()
],
'description' => [
'type' => Type::string()
],
'img_url' => [
'type' => Type::string()
],
'created_at' => [
'type' => Type::string()
],
'updated_at' => [
'type' => Type::string()
],
'SubBusinessFields' => [
'type' => Type::listOf(GraphQL::type('SubBusinessField'))
],
];
}
I've dd()
the id
and it was correct.
I've also tried id type instead of string but nothing changed.
How to fix this issue?
Just added this line to my Model
and it got fixed!
public $incrementing = false;
It was weird that I couldn't find any similar problem anywhere else.