0

I have a laravel package which uses GraphQL (Lighthouse) to extend my base project(s). Everything works fine when adding my package and doing queries etc.

But since I try to make a postGraphQL request within my testing file, where the given query or mutation utilizes the @broadcast Directive, the request fails saying:

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

The SubscriptionServiceProvider is added to providers array of app config when booting the test environment. I use orchestra/testbench and add the provider within the getEnvironmentSetUp method.

But I think that the generated postGraphQL request doesn't have the SubscriptionServiceProvider added. I traced it back to the Illuminate\Foundation\Testing\Concerns\MakesHttpRequest class which creates a new kernel object that does the request and doesn't seem to boot up as it should.

Maybe the problem is me being within a laravel package and not in a "regular" laravel project, where one would define the SubscriptionServiceProvider within config/app.php.

Is this a bug or am I missing something? Anybody here who had this problem as well? I couldn't find anything here or googling around unfortunately.

carsten
  • 191
  • 1
  • 2
  • 7

1 Answers1

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 :)

carsten
  • 191
  • 1
  • 2
  • 7