From ac5df24981fb1da0b06eab9abda2cc9447768f33 Mon Sep 17 00:00:00 2001 From: Kyrch Date: Sun, 30 Nov 2025 10:07:05 -0300 Subject: [PATCH] fix(graphql): default to v1 schema (#1015) --- .../Models/Wiki/Image/OptimizeImageAction.php | 2 +- .../{DefaultSchema.php => V1Schema.php} | 19 +++++----- config/graphql.php | 37 +++++++------------ config/pulse.php | 4 +- 4 files changed, 26 insertions(+), 36 deletions(-) rename app/GraphQL/Schema/Schemas/{DefaultSchema.php => V1Schema.php} (96%) diff --git a/app/Actions/Models/Wiki/Image/OptimizeImageAction.php b/app/Actions/Models/Wiki/Image/OptimizeImageAction.php index 3ed65b8cb..bee040216 100644 --- a/app/Actions/Models/Wiki/Image/OptimizeImageAction.php +++ b/app/Actions/Models/Wiki/Image/OptimizeImageAction.php @@ -93,7 +93,7 @@ class OptimizeImageAction } if ($this->width !== null && $this->height !== null) { - $imagePath = $this->downscaleImage($imagePath); + return $this->downscaleImage($imagePath); } return $imagePath; diff --git a/app/GraphQL/Schema/Schemas/DefaultSchema.php b/app/GraphQL/Schema/Schemas/V1Schema.php similarity index 96% rename from app/GraphQL/Schema/Schemas/DefaultSchema.php rename to app/GraphQL/Schema/Schemas/V1Schema.php index 06ccfadd7..096c0ad3c 100644 --- a/app/GraphQL/Schema/Schemas/DefaultSchema.php +++ b/app/GraphQL/Schema/Schemas/V1Schema.php @@ -88,15 +88,18 @@ use App\GraphQL\Schema\Unions\PerformanceArtistUnion; use App\GraphQL\Schema\Unions\ResourceableUnion; use App\Http\Middleware\GraphQL\LogGraphQLRequest; use App\Http\Middleware\GraphQL\MaxCount; -use App\Http\Middleware\GraphQL\RateLimitPerQuery; -use App\Http\Middleware\GraphQL\SetServingGraphQL; +use Illuminate\Support\Facades\Config; +use Rebing\GraphQL\GraphQLController; use Rebing\GraphQL\Support\Contracts\ConfigConvertible; -class DefaultSchema implements ConfigConvertible +class V1Schema implements ConfigConvertible { public function toConfig(): array { return [ + // Also supported array syntax: `[\Rebing\GraphQL\GraphQLController::class, 'query']` + 'controller' => GraphQLController::class.'@query', + 'query' => [ // Admin AnnouncementPaginationQuery::class, @@ -220,12 +223,6 @@ class DefaultSchema implements ConfigConvertible ], // Laravel HTTP middleware 'middleware' => [ - // Rate limiting GraphQL to prevent abuse. - RateLimitPerQuery::class, - - // Set the serving context to graphql. - SetServingGraphQL::class, - // Allow client to get full database. MaxCount::class, @@ -237,6 +234,10 @@ class DefaultSchema implements ConfigConvertible // An array of middlewares, overrides the global ones 'execution_middleware' => [], + + 'route_attributes' => [ + 'domain' => Config::get('graphql.domain'), + ], ]; } } diff --git a/config/graphql.php b/config/graphql.php index 00b589ce0..f68e703cc 100644 --- a/config/graphql.php +++ b/config/graphql.php @@ -2,28 +2,32 @@ declare(strict_types=1); -use App\GraphQL\Schema\Schemas\DefaultSchema; +use App\GraphQL\Schema\Schemas\V1Schema; use App\GraphQL\Schema\Types\Base\PaginationInfoType; +use App\Http\Middleware\GraphQL\RateLimitPerQuery; +use App\Http\Middleware\GraphQL\SetServingGraphQL; return [ + 'domain' => env('GRAPHQL_DOMAIN_NAME', env('APP_URL')), + 'rate_limit' => (int) env('GRAPHQL_RATE_LIMIT', 80), 'route' => [ // The prefix for routes; do NOT use a leading slash! 'prefix' => env('GRAPHQL_PATH', '/'), - // The controller/method to use in GraphQL request. // Also supported array syntax: `[\Rebing\GraphQL\GraphQLController::class, 'query']` 'controller' => Rebing\GraphQL\GraphQLController::class.'@query', - // Any middleware for the graphql route group // This middleware will apply to all schemas - 'middleware' => [], + 'middleware' => [ + // Set the serving context to graphql. + SetServingGraphQL::class, + // Rate limiting GraphQL to prevent abuse. + RateLimitPerQuery::class, + ], // Additional route group attributes - // - // Example: - // // 'group_attributes' => ['guard' => 'api'] // 'group_attributes' => [ @@ -33,7 +37,7 @@ return [ // The name of the default schema // Used when the route group is directly accessed - 'default_schema' => 'default', + 'default_schema' => 'v1', 'batching' => [ // Whether to support GraphQL batching or not. @@ -45,8 +49,6 @@ return [ // The schemas for query and/or mutation. It expects an array of schemas to provide // both the 'query' fields and the 'mutation' fields. // - // You can also provide a middleware that will only apply to the given schema - // // Example: // // 'schemas' => [ @@ -71,17 +73,13 @@ return [ // ] // 'schemas' => [ - 'default' => DefaultSchema::class, + 'v1' => V1Schema::class, ], // The global types available to all schemas. - // You can then access it from the facade like this: GraphQL::type('user') 'types' => [ // Pagination PaginationInfoType::class, - // ExampleType::class, - // ExampleRelationType::class, - // \Rebing\GraphQL\Support\UploadType::class, ], // This callable will be passed the Error object for each errors GraphQL catch. @@ -124,19 +122,16 @@ return [ ], /* - * You can define your own pagination type. * Reference \Rebing\GraphQL\Support\PaginationType::class */ 'pagination_type' => App\GraphQL\Schema\Types\Base\PaginationType::class, /* - * You can define your own simple pagination type. * Reference \Rebing\GraphQL\Support\SimplePaginationType::class */ 'simple_pagination_type' => Rebing\GraphQL\Support\SimplePaginationType::class, /* - * You can define your own cursor pagination type. * Reference Rebing\GraphQL\Support\CursorPaginationType::class */ 'cursor_pagination_type' => Rebing\GraphQL\Support\CursorPaginationType::class, @@ -193,9 +188,6 @@ return [ 'cache_ttl' => 300, ], - /* - * Execution middlewares - */ 'execution_middleware' => [ Rebing\GraphQL\Support\ExecutionMiddleware\ValidateOperationParamsMiddleware::class, // AutomaticPersistedQueriesMiddleware listed even if APQ is disabled, see the docs for the `'apq'` configuration @@ -204,8 +196,5 @@ return [ // \Rebing\GraphQL\Support\ExecutionMiddleware\UnusedVariablesMiddleware::class, ], - /* - * Globally registered ResolverMiddleware - */ 'resolver_middleware_append' => null, ]; diff --git a/config/pulse.php b/config/pulse.php index 4ee5f08d1..cc7a8e3bb 100644 --- a/config/pulse.php +++ b/config/pulse.php @@ -19,7 +19,7 @@ return [ | */ - 'domain' => env('FILAMENT_DOMAIN'), + 'domain' => env('FILAMENT_DOMAIN_NAME'), /* |-------------------------------------------------------------------------- @@ -32,7 +32,7 @@ return [ | */ - 'path' => env('FILAMENT_DOMAIN') ? env('PULSE_PATH', 'pulse') : env('FILAMENT_PATH').'/pulse', + 'path' => env('FILAMENT_DOMAIN_NAME') ? env('PULSE_PATH', 'pulse') : env('FILAMENT_PATH').'/pulse', /* |--------------------------------------------------------------------------