Replies: 1 comment 1 reply
-
To get your Laravel + Lighthouse + Pusher subscription setup working with Flutter, it's important to ensure all components are properly configured and compatible. Based on your detailed description, here are some common issues and their solutions:
Laravel WebSocket Package:
Start the WebSocket server:
If you're deploying to production, use:
Then, verify that jobs are being dispatched and processed. Check jobs table logs if you're using the database queue.
}` Ensure you’ve registered this subscription in the lighthouse.php config.
For local:
For production (Pusher):
Manually Test Events: Test Pusher by broadcasting a manual event to see if it reaches the Pusher console:
Example:
Combine them:
Conclusion |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm a complete beginner, unfortunately with Laravel, also with Lighthouse, and with Pusher. I want to develop a mobile app with Flutter that should communicate with a Laravel backend via graphQL. The queries and mutations work. Subscriptions don't work at all, no matter what I do. Can anyone give me a tip?
Currently I am trying to get the following configuration to work:
First, I created a completely new laravel project, via:
I've added
Nuwave\Lighthouse\Subscriptions\SubscriptionServiceProvider::class,
in bootstrap\providers.php.I've created two models, author and blog, as well as a, in my opinion, suitable scheme:
In .env I defined the pusher variables:
The mutation:
works. It always creates a new record in the database. The job
Nuwave\Lighthouse\Subscriptions\BroadcastSubscriptionJob
is queued and is executed shortly afterwards. There are no errors in the laravel.log. But nothing appears in the pusher debug console.Before that, I start the subscription:
in the hope that this will notify me of the new blog-entry. Nothing happens via the Altair GraphQL client. This request also does not arrive in the pusher debug console. Via graphiQL, the connection breaks immediately or is not established at all, the error message is:
"errors": [ { "isTrusted": true } ]
The functions authorize and filter of class BlogInserted (extends GraphQLSubscription) returns constant true.
Because I'm not sure, I'm testing with two different subscriptions URLs:
a.)
GRAPHIQL_SUBSCRIPTION_ENDPOINT="ws://127.0.0.1:8801/graphql"
b.)
GRAPHIQL_SUBSCRIPTION_ENDPOINT="wss://ws-${PUSHER_APP_CLUSTER}.pusher.com:443/app/${PUSHER_APP_KEY}?protocol=7"
Does anyone have an idea how I can find my mistake?
Beta Was this translation helpful? Give feedback.
All reactions