mirror of
https://github.com/AnimeThemes/animethemes-server.git
synced 2026-07-11 01:24:46 +02:00
feat(graphql): siteUrl attribute (#1212)
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\GraphQL\Types;
|
||||
|
||||
use App\Models\Wiki\Anime;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class AnimeType
|
||||
{
|
||||
public function resolveSiteUrlAttribute(Anime $anime): string
|
||||
{
|
||||
return Str::of(Config::get('app.url'))
|
||||
->append('/anime/')
|
||||
->append($anime->slug)
|
||||
->__toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\GraphQL\Types;
|
||||
|
||||
use App\Models\Wiki\Artist;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ArtistType
|
||||
{
|
||||
public function resolveSiteUrlAttribute(Artist $artist): string
|
||||
{
|
||||
return Str::of(Config::get('app.url'))
|
||||
->append('/artist/')
|
||||
->append($artist->slug)
|
||||
->__toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\GraphQL\Types;
|
||||
|
||||
use App\Models\List\Playlist;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class PlaylistType
|
||||
{
|
||||
public function resolveSiteUrlAttribute(Playlist $playlist): string
|
||||
{
|
||||
return Str::of(Config::get('app.url'))
|
||||
->append('/playlist/')
|
||||
->append($playlist->hashid)
|
||||
->__toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\GraphQL\Types;
|
||||
|
||||
use App\Models\Wiki\Series;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class SeriesType
|
||||
{
|
||||
public function resolveSiteUrlAttribute(Series $series): string
|
||||
{
|
||||
return Str::of(Config::get('app.url'))
|
||||
->append('/series/')
|
||||
->append($series->slug)
|
||||
->__toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\GraphQL\Types;
|
||||
|
||||
use App\Models\Wiki\Studio;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class StudioType
|
||||
{
|
||||
public function resolveSiteUrlAttribute(Studio $studio): string
|
||||
{
|
||||
return Str::of(Config::get('app.url'))
|
||||
->append('/studio/')
|
||||
->append($studio->slug)
|
||||
->__toString();
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,9 @@ type Playlist @model(class: "App\\Models\\List\\Playlist") {
|
||||
"The number of likes recorded for the resource"
|
||||
likesCount: Int! @aggregateCustom(column: "value", function: SUM, relation: "likeAggregate")
|
||||
|
||||
"The URL for the playlist page on the website"
|
||||
siteUrl: String! @field(resolver: "App\\GraphQL\\Types\\PlaylistType@resolveSiteUrlAttribute")
|
||||
|
||||
"The date that the resource was created"
|
||||
createdAt(format: String! = "Y-m-d H:i:s"): String @timestamp(attribute: "created_at")
|
||||
|
||||
|
||||
@@ -31,6 +31,9 @@ type Anime @model(class: "App\\Models\\Wiki\\Anime") {
|
||||
"The premiere year of the anime"
|
||||
year: Int
|
||||
|
||||
"The URL for the anime page on the website"
|
||||
siteUrl: String! @field(resolver: "App\\GraphQL\\Types\\AnimeType@resolveSiteUrlAttribute")
|
||||
|
||||
"The date that the resource was created"
|
||||
createdAt(format: String! = "Y-m-d H:i:s"): String @timestamp(attribute: "created_at")
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@ type Artist @model(class: "App\\Models\\Wiki\\Artist") {
|
||||
"The brief information of the resource"
|
||||
information: String
|
||||
|
||||
"The URL for the artist page on the website"
|
||||
siteUrl: String! @field(resolver: "App\\GraphQL\\Types\\ArtistType@resolveSiteUrlAttribute")
|
||||
|
||||
"The date that the resource was created"
|
||||
createdAt(format: String! = "Y-m-d H:i:s"): String @timestamp(attribute: "created_at")
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ type Series @model(class: "App\\Models\\Wiki\\Series") {
|
||||
"The URL slug & route key of the resource"
|
||||
slug: String!
|
||||
|
||||
"The URL for the series page on the website"
|
||||
siteUrl: String! @field(resolver: "App\\GraphQL\\Types\\SeriesType@resolveSiteUrlAttribute")
|
||||
|
||||
"The date that the resource was created"
|
||||
createdAt(format: String! = "Y-m-d H:i:s"): String @timestamp(attribute: "created_at")
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ type Studio @model(class: "App\\Models\\Wiki\\Studio") {
|
||||
"The URL slug & route key of the resource"
|
||||
slug: String!
|
||||
|
||||
"The URL for the studio page on the website"
|
||||
siteUrl: String! @field(resolver: "App\\GraphQL\\Types\\StudioType@resolveSiteUrlAttribute")
|
||||
|
||||
"The date that the resource was created"
|
||||
createdAt(format: String! = "Y-m-d H:i:s"): String @timestamp(attribute: "created_at")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user