首页 > 解决方案 > laravel graphql playground 设置时出错

问题描述

在灯塔教程中设置此软件包时,出现此错误我现在可以做什么?

https://github.com/mll-lab/laravel-graphql-playground

作曲家

"require": {
        "php": "^7.1.3",
        "fideloper/proxy": "^4.0",
        "laravel/framework": "5.7.*",
        "laravel/tinker": "^1.0",
        "mll-lab/laravel-graphql-playground": "^1.0",
        "nuwave/lighthouse": "^2.6"
    },

错误

In Router.php line 363:  
Argument 1 passed to Illuminate\Routing\Router::group() must be of the type array, string giv     en,
called in D:\Laravel\lighthouse-tutorial\vendor\laravel\framework\src\Illuminate\Support\ Facades\Facade.php on line 223
--
In Router.php line 363:  
Argument 1 passed to Illuminate\Routing\Router::group() must be of the type
array, string given, called in D:\Laravel\lighthouse-tutorial\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php on line 223
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with er ror code 1
--

更新

配置文件

<?php

return [
    // Route for the frontend
    'route' => 'graphql-playground',

    // Which middleware to apply, if any
    'middleware' => [
        // 'web',
    ],

    // Route for the GraphQL endpoint
    'endpoint' => 'graphql',

    // Control if the playground is accessible at all
    // This allows you to disable it completely in production
    'enabled' => env('GRAPHQL_PLAYGROUND_ENABLED', true),
];

当我删除它时问题就在这里'route' => 'graphql-playground',

标签: phplaravelgraphqllaravel-lighthouse

解决方案


我发现GraphQLPlaygroundServiceProvider.php他们正在使用路由组:

Route::group(
    config('graphql-playground.route'),
...

但是路由组需要一个数组参数,所以我通过更改配置文件解决了这个问题:

'route' => 'graphql-playground',

作为数组的路由:

'route' => ['graphql-playground'],

这为我解决了这个问题。


推荐阅读