This repository was archived by the owner on Feb 14, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +32
-7
lines changed Expand file tree Collapse file tree 3 files changed +32
-7
lines changed Original file line number Diff line number Diff line change @@ -16,20 +16,28 @@ Easily integrate [GraphQL Playground](https://github.com/prismagraphql/graphql-p
16
16
17
17
If you are using Laravel < 5.4, add the service provider to your ` config/app.php `
18
18
19
- ```` php
19
+ ``` php
20
20
'providers' => [
21
21
// Other providers...
22
22
MLL\\GraphQLPlayground\\GraphQLPlaygroundServiceProvider::class,
23
23
]
24
- ````
24
+ ```
25
25
26
26
You may publish the configuration and/or the views:
27
27
28
- php artisan vendor:publish
28
+ php artisan vendor:publish --provider="MLL\GraphQLPlayground\GraphQLPlaygroundServiceProvider"
29
29
30
30
## Usage
31
31
32
32
By default, the playground is reachable at ` /graphql-playground `
33
33
34
34
It assumes a running GraphQL endpoint at ` /graphql ` . You can enter another URL in the
35
35
UI or change the default setting in the configuration file.
36
+
37
+ ## Security
38
+
39
+ If you do not want to enable the GraphQL playground in production, you can disable it in the config file.
40
+ The easiest way is to set the environment variable ` GRAPHQL_PLAYGROUND_ENABLED=false `
41
+
42
+ If you want to add custom middleware to protect the route to the GraphQL playground, you can
43
+ add it in the configuration file.
Original file line number Diff line number Diff line change 3
3
return [
4
4
// Route for the frontend
5
5
'route ' => 'graphql-playground ' ,
6
-
6
+
7
+ // Which middleware to apply, if any
8
+ 'middleware ' => [
9
+ // 'web',
10
+ ],
11
+
7
12
// Route for the GraphQL endpoint
8
13
'endpoint ' => 'graphql ' ,
14
+
15
+ // Control if the playground is accessible at all
16
+ // This allows you to disable it completely in production
17
+ 'enabled ' => env ('GRAPHQL_PLAYGROUND_ENABLED ' , true ),
9
18
];
Original file line number Diff line number Diff line change @@ -26,9 +26,17 @@ public function boot()
26
26
self ::VIEW_PATH => resource_path ('views/vendor/graphql-playground ' ),
27
27
], 'views ' );
28
28
29
- \Route::get (config ('graphql-playground.route ' ), function () {
30
- return view ('graphql-playground::index ' );
31
- });
29
+ if (!config ('graphql-playground.enabled ' , true )) {
30
+ return ;
31
+ }
32
+
33
+ \Route::get (config ('graphql-playground.route ' ), [
34
+ 'middleware ' => config ('graphql-playground.middleware ' , '' ),
35
+ 'as ' => 'graphql-playgroundcontroller ' ,
36
+ 'uses ' => function () {
37
+ return view ('graphql-playground::index ' );
38
+ },
39
+ ]);
32
40
}
33
41
34
42
/**
You can’t perform that action at this time.
0 commit comments