Skip to content
This repository was archived by the owner on Feb 14, 2023. It is now read-only.

Commit b07606b

Browse files
authored
Merge pull request #18 from ddedic/route-config
Add better support for route config
2 parents 78264c5 + fdec14a commit b07606b

File tree

2 files changed

+51
-13
lines changed

2 files changed

+51
-13
lines changed

config/graphql-playground.php

Lines changed: 43 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,53 @@
33
declare(strict_types=1);
44

55
return [
6-
// Route for the frontend
7-
'route' => 'graphql-playground',
6+
/*
7+
|--------------------------------------------------------------------------
8+
| GraphQL Playground endpoint
9+
|--------------------------------------------------------------------------
10+
|
11+
| Set the endpoint to which the GraphQL Playground responds.
12+
| The default route endpoint is "yourdomain.com/graphql-playground".
13+
|
14+
*/
815

9-
// Which middleware to apply, if any
10-
'middleware' => [
11-
// 'web',
16+
'route_name' => 'graphql-playground',
17+
18+
/*
19+
|--------------------------------------------------------------------------
20+
| Route configuration
21+
|--------------------------------------------------------------------------
22+
|
23+
| Additional configuration for the route group https://lumen.laravel.com/docs/routing#route-groups
24+
|
25+
| For domain config it could be something like:
26+
| 'domain' => 'graphql.' . env('APP_DOMAIN', 'localhost'),
27+
*/
28+
29+
'route' => [
30+
// 'prefix' => '',
31+
// 'middleware' => ['web']
32+
'domain' => env('GRAPHQL_PLAYGROUND_DOMAIN', null),
1233
],
1334

14-
// Route for the GraphQL endpoint
35+
/*
36+
|--------------------------------------------------------------------------
37+
| Route for the GraphQL endpoint
38+
|--------------------------------------------------------------------------
39+
|
40+
*/
41+
1542
'endpoint' => 'graphql',
1643

17-
// Control if the playground is accessible at all
18-
// This allows you to disable it completely in production
44+
/*
45+
|--------------------------------------------------------------------------
46+
| Route for the GraphQL endpoint
47+
|--------------------------------------------------------------------------
48+
|
49+
| Control if the playground is accessible at all
50+
| This allows you to disable it completely in production
51+
|
52+
*/
53+
1954
'enabled' => env('GRAPHQL_PLAYGROUND_ENABLED', true),
2055
];

src/GraphQLPlaygroundServiceProvider.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ public function boot()
3232
return;
3333
}
3434

35-
\Route::get(
35+
\Route::group(
3636
config('graphql-playground.route'),
37-
GraphQLPlaygroundController::class.'@get'
38-
)->middleware(
39-
config('graphql-playground.middleware')
40-
)->name('graphql-playground');
37+
function (): void {
38+
\Route::get(
39+
config('graphql-playground.route_name', 'graphql-playground'),
40+
GraphQLPlaygroundController::class.'@get'
41+
)->name('graphql-playground');
42+
}
43+
);
4144
}
4245

4346
/**

0 commit comments

Comments
 (0)