在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):mll-lab/laravel-graphql-playground开源软件地址(OpenSource Url):https://github.com/mll-lab/laravel-graphql-playground开源编程语言(OpenSource Language):PHP 84.2%开源软件介绍(OpenSource Introduction):Laravel GraphQL PlaygroundEasily integrate GraphQL Playground into your Laravel projects.
Installation
If you are using Lumen, register the service provider in $app->register(MLL\GraphQLPlayground\GraphQLPlaygroundServiceProvider::class); ConfigurationBy default, the playground is reachable at To change the defaults, publish the configuration with the following command:
You will find the configuration file at LumenIf you are using Lumen, copy it into that location manually and load the configuration
in your $app->configure('graphql-playground'); HTTPS behind proxyIf your application sits behind a proxy which resolves https, the generated URL for the endpoint
will not be using if (! $this->app->isLocal()) {
\Illuminate\Support\Facades\URL::forceScheme('https');
} CustomizationTo customize the Playground even further, publish the view:
You can use that for all kinds of customization. Change settings of the playground instanceAdd extra settings in the call to GraphQLPlayground.init(document.getElementById('root'), {
endpoint: "{{ url(config('graphql-playground.endpoint')) }}",
subscriptionEndpoint: "{{ config('graphql-playground.subscriptionEndpoint') }}",
// See https://github.com/graphql/graphql-playground#properties for available settings
}) Configure session authenticationSession based authentication can be used with Laravel Sanctum.
If you use GraphQL through sessions and CSRF, add the following to the <meta name="csrf-token" content="{{ csrf_token() }}"> Modify the Playground config: GraphQLPlayground.init(document.getElementById('root'), {
endpoint: "{{ url(config('graphql-playground.endpoint')) }}",
subscriptionEndpoint: "{{ config('graphql-playground.subscriptionEndpoint') }}",
+ settings: {
+ 'request.credentials': 'same-origin',
+ },
+ headers: {
+ 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
+ }
}) Make sure your route includes the 'route' => [
'uri' => '/graphql-playground',
'name' => 'graphql-playground',
+ 'middleware' => ['web']
] Local assetsIf you want to serve the assets from your own server, you can download them with the command
This puts the necessary CSS, JS and Favicon into your SecurityIf you do not want to enable the GraphQL playground in production, you can disable it in the config file.
The easiest way is to set the environment variable If you want to protect the route to the GraphQL playground, you can add custom middleware in the config file. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论