|
79 | 79 | $prefix = config()->get('api-platform.defaults.route_prefix', ''); |
80 | 80 |
|
81 | 81 | Route::group(['prefix' => $prefix], static function (): void { |
| 82 | + if (config()->get('api-platform.graphql.enabled')) { |
| 83 | + Route::group([ |
| 84 | + 'middleware' => config()->get('api-platform.graphql.middleware', []), |
| 85 | + ], static function (): void { |
| 86 | + Route::addRoute(['POST', 'GET'], '/graphql', GraphQlEntrypointController::class) |
| 87 | + ->name('api_graphql'); |
| 88 | + }); |
| 89 | + |
| 90 | + if (config()->get('api-platform.graphiql.enabled', true)) { |
| 91 | + Route::group([ |
| 92 | + 'middleware' => config()->get('api-platform.graphiql.middleware', []), |
| 93 | + 'domain' => config()->get('api-platform.graphiql.domain', ''), |
| 94 | + ], static function (): void { |
| 95 | + Route::get('/graphiql', GraphiQlController::class) |
| 96 | + ->name('api_graphiql'); |
| 97 | + }); |
| 98 | + } |
| 99 | + } |
| 100 | + |
82 | 101 | Route::group(['middleware' => ApiPlatformMiddleware::class], static function (): void { |
83 | 102 | Route::get('/contexts/{shortName?}{_format?}', static function (Request $request, ContextAction $contextAction, string $shortName = 'Entrypoint') { |
84 | 103 | return $contextAction($shortName, $request); |
|
98 | 117 | ->where('index', 'index') |
99 | 118 | ->name('api_entrypoint'); |
100 | 119 | }); |
101 | | - |
102 | | - if (config()->get('api-platform.graphql.enabled')) { |
103 | | - Route::group([ |
104 | | - 'middleware' => config()->get('api-platform.graphql.middleware', []), |
105 | | - ], static function (): void { |
106 | | - Route::addRoute(['POST', 'GET'], '/graphql', GraphQlEntrypointController::class) |
107 | | - ->name('api_graphql'); |
108 | | - }); |
109 | | - |
110 | | - if (config()->get('api-platform.graphiql.enabled', true)) { |
111 | | - Route::group([ |
112 | | - 'middleware' => config()->get('api-platform.graphiql.middleware', []), |
113 | | - 'domain' => config()->get('api-platform.graphiql.domain', ''), |
114 | | - ], static function (): void { |
115 | | - Route::get('/graphiql', GraphiQlController::class) |
116 | | - ->name('api_graphiql'); |
117 | | - }); |
118 | | - } |
119 | | - } |
120 | 120 | }); |
121 | 121 | }); |
122 | 122 |
|
|
0 commit comments