0

我有一个 laravel 包,它使用 GraphQL (Lighthouse) 来扩展我的基础项目。添加我的包和进行查询等时一切正常。

但是,由于我尝试在我的测试文件中发出postGraphQL请求,其中给定的查询或突变利用了@broadcast指令,所以请求失败并说:

Add the SubscriptionServiceProvider to your config/app.php to enable subscriptions.

SubscriptionServiceProvider启动测试环境时添加到应用程序配置提供者数组中。我使用 orchestra/testbench 并在getEnvironmentSetUp方法中添加提供程序。

但我认为生成的postGraphQL请求没有SubscriptionServiceProvider添加。我将其追溯到Illuminate\Foundation\Testing\Concerns\MakesHttpRequest创建一个新内核对象的类,该对象执行请求并且似乎没有按应有的方式启动。

也许问题是我在一个 laravel 包中,而不是在一个“常规” laravel 项目中,在那里人们会定义SubscriptionServiceProviderconfig/app.php 中定义。

这是一个错误还是我错过了什么?这里有人也有这个问题吗?不幸的是,我在这里找不到任何东西或谷歌搜索。

4

1 回答 1

0

I solved it! Instead of trying to add the SubscriptionServiceProvider to the app environment using the getEnvironmentSetUp method of orchestra I now add it within the method getPackageProviders together with the LighthouseServiceProvider like so:

protected function getPackageProviders($app)
{
    return [
        LighthouseServiceProvider::class,
        SubscriptionServiceProvider::class,
        MyOwnPackageProvider::class,
    ];
}

And it works like a charm :)

于 2020-02-19T13:33:40.693 回答