fix(graphql): fixed eager load nodes children (#949)

This commit is contained in:
Kyrch
2025-09-02 10:13:40 -03:00
committed by GitHub
parent a4ef61b134
commit 69c748dd9c
3 changed files with 49 additions and 36 deletions
@@ -122,6 +122,7 @@ trait ConstrainsEagerLoads
$this->sort($query, $args, $type);
$child = Arr::get($selection, 'selectionSet.data.data.selectionSet')
?? Arr::get($selection, 'selectionSet.nodes.nodes.selectionSet')
?? Arr::get($selection, 'selectionSet', []);
$this->processEagerLoadForType($query, $child, $type);
+30 -18
View File
@@ -62,18 +62,16 @@ class Imageable extends BaseMorphPivot
protected $table = Imageable::TABLE;
/**
* Get the composite primary key for the pivot.
* The attributes that are mass assignable.
*
* @return string[]
* @var list<string>
*/
protected function getPrimaryKeys(): array
{
return [
Imageable::ATTRIBUTE_IMAGE,
Imageable::ATTRIBUTE_IMAGEABLE_TYPE,
Imageable::ATTRIBUTE_IMAGEABLE_ID,
];
}
protected $fillable = [
Imageable::ATTRIBUTE_DEPTH,
Imageable::ATTRIBUTE_IMAGE,
Imageable::ATTRIBUTE_IMAGEABLE_TYPE,
Imageable::ATTRIBUTE_IMAGEABLE_ID,
];
/**
* The event map for the model.
@@ -89,16 +87,30 @@ class Imageable extends BaseMorphPivot
];
/**
* The attributes that are mass assignable.
* Get the composite primary key for the pivot.
*
* @var list<string>
* @return string[]
*/
protected $fillable = [
Imageable::ATTRIBUTE_DEPTH,
Imageable::ATTRIBUTE_IMAGE,
Imageable::ATTRIBUTE_IMAGEABLE_TYPE,
Imageable::ATTRIBUTE_IMAGEABLE_ID,
];
protected function getPrimaryKeys(): array
{
return [
Imageable::ATTRIBUTE_IMAGE,
Imageable::ATTRIBUTE_IMAGEABLE_TYPE,
Imageable::ATTRIBUTE_IMAGEABLE_ID,
];
}
/**
* Get the attributes that should be cast.
*
* @return array<string, string>
*/
protected function casts(): array
{
return [
Imageable::ATTRIBUTE_DEPTH => 'int',
];
}
/**
* Gets the image that owns the imageable.
+18 -18
View File
@@ -64,18 +64,16 @@ class Resourceable extends BaseMorphPivot
protected $table = Resourceable::TABLE;
/**
* Get the composite primary key for the pivot.
* The attributes that are mass assignable.
*
* @return string[]
* @var list<string>
*/
protected function getPrimaryKeys(): array
{
return [
Resourceable::ATTRIBUTE_RESOURCE,
Resourceable::ATTRIBUTE_RESOURCEABLE_TYPE,
Resourceable::ATTRIBUTE_RESOURCEABLE_ID,
];
}
protected $fillable = [
Resourceable::ATTRIBUTE_AS,
Resourceable::ATTRIBUTE_RESOURCE,
Resourceable::ATTRIBUTE_RESOURCEABLE_TYPE,
Resourceable::ATTRIBUTE_RESOURCEABLE_ID,
];
/**
* The event map for the model.
@@ -91,16 +89,18 @@ class Resourceable extends BaseMorphPivot
];
/**
* The attributes that are mass assignable.
* Get the composite primary key for the pivot.
*
* @var list<string>
* @return string[]
*/
protected $fillable = [
Resourceable::ATTRIBUTE_AS,
Resourceable::ATTRIBUTE_RESOURCE,
Resourceable::ATTRIBUTE_RESOURCEABLE_TYPE,
Resourceable::ATTRIBUTE_RESOURCEABLE_ID,
];
protected function getPrimaryKeys(): array
{
return [
Resourceable::ATTRIBUTE_RESOURCE,
Resourceable::ATTRIBUTE_RESOURCEABLE_TYPE,
Resourceable::ATTRIBUTE_RESOURCEABLE_ID,
];
}
/**
* Gets the resource that owns the resourceable.