relation; } public function resolve($root, array $args, $context, ResolveInfo $resolveInfo): mixed { return $root->hasAttribute($attribute = "{$this->relation}_count") ? (int) $root->getAttribute($attribute) : $root->{$this->relation}->count(); } }