Skip to content

Commit

Permalink
Fix GraphQL
Browse files Browse the repository at this point in the history
  • Loading branch information
aerni committed Jul 19, 2024
1 parent a968b39 commit 45839f7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/GraphQL/Fields/SitemapField.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function type(): Type
return GraphQL::listOf(GraphQL::type(SeoSitemapType::NAME));
}

public function resolve($root, $args, $context, ResolveInfo $info): ?Collection
public function resolve($root, $args, $context, ResolveInfo $info): ?array
{
$sitemaps = Sitemap::{"{$info->fieldName}Sitemaps"}();

Expand All @@ -55,9 +55,9 @@ public function resolve($root, $args, $context, ResolveInfo $info): ?Collection
$sitemapUrls = $sitemaps->flatMap->urls();

if ($site = $args['site'] ?? null) {
$sitemapUrls = $sitemapUrls->where('site', $site);
$sitemapUrls = $sitemapUrls->filter(fn ($url) => $url->site() === $site);
}

return $sitemapUrls->isNotEmpty() ? $sitemapUrls : null;
return $sitemapUrls->isNotEmpty() ? $sitemapUrls->toArray() : null;
}
}

0 comments on commit 45839f7

Please sign in to comment.