This project contains the implementation of Lighthouse subscription with pusher/laravel-websockets. If you're looking for the implementation of echo driver, then check the implementation in this repository.
This repository contains Laravel 8.x and Lighthouse 5.2.x
This project comes with docker & docker-compose. But to minimize the boot up time when you try docker-compose up -d --build the local files are mounted to application & worker containers and NOT COPIED TO CONTAINERS.
Thus, it's recommended to use PHP & composer locally. Resolve your project dependency before you run your application using composer install.
But you need node environment to build the JS dependency if you're not using pusher but the echo driver for subscription. Follow the attached article.
- Clone the repository.
cp docker-compose.yml.example docker-compose.yml.- Make the required changes to your
docker-compose.yml. cp .env.example .env.- Make the required changes to your
.env. - Run
php artisan key:generateto generate application key. touch database/database.sqliteto create sqlite database.php artisan migrateto migrate the database.yarn installto install the dependencies.yarn run watchto build the JS files.docker-compose up -d --buildto build your containers.- Loading
http://127.0.0.1:{PHP_PORT}in your browser will return a json response. - If you don't have
composerlocally, thenexec-ing to php container after containers are up and install the dependencies will work. Just restart the containers. - If you're changing the environment variables, make sure to change them other places and run commands if required.
- Open served application in your browser. It's on port
8000. Change the port if you changed in thedocker-compose.yml's php port. - Open playground url in your browser. It's on port
8000. Change the port if you changed thedocker-compose.yml's php port. - Check the browser's console log if everything is okay or not.
- Run the following mutation from the playground.
mutation createUser{
createUser (name: "A") {
id
name
email
created_at
updated_at
has_arg
pushed_by_subs_resolver
}
}- You'll get to see the update in your application homepage.
- Otherwise, click the button on the homepage, you'll see the value gets updated.
- Comment the pusher related variables and imports in
resources/js/apollo.js. - Uncomment and change the url that points to the other project that has
echodriver implemented inresources/js/apollo.js. - Copy a JWT token from the other project's login mutation.
- Open inspect element.
- Add the copied jwt token in your page's
localStoragewith the keytoken. - Build the project with
yarn run watch. - Reload the page.
- Click the button.
Wait for a few seconds as the other project uses queue to push the data to echo server (by default). And you should be able to see the data changing.