Figured it out after a few days. Essentially I needed to create a custom resolver.
schema.graphql
type Query {
forumCategoryBySlug(slug: String! @eq): ForumCategory
}
app/GraphQL/Queries/ForumCategoryBySlug.php
<?php
namespace App\GraphQL\Queries;
use App\Models\ForumCategory;
class ForumCategoryBySlug
{
/**
* @param null $_
* @param array<string, mixed> $args
*/
public function __invoke($_, array $args)
{
$category = \App\Models\ForumCategory::findBySlug($args["slug"])->first();
return $category;
}
}
CLICK HERE to find out more related problems solutions.