-
-
Notifications
You must be signed in to change notification settings - Fork 465
Closed
Description
My lighthouse broadcasting is not working. I followed the instructions mentioned in the docs, but it is not working.
Here are my codes.
message.graphql (which is imported in the schema.graphql)
type Subscription {
messageSent(chatId: ID): Message! @subscription(class: "App\\GraphQL\\Subscriptions\\MessageSent")
}
extend type Mutation {
sendMessage(
messageId: ID @rules(apply: ["nullable", "exists:messages,id,deletedAt,NULL"])
chatId: ID! @rules(apply: ["required", "exists:chats,id,deletedAt,NULL"])
userId: ID! @rules(apply: ["required", "exists:users,id,deletedAt,NULL"])
message: String! @rules(apply: ["required", "max:2024"])
): Message! @create @guard @broadcast(subscription: "messageSent")
reactOnMessage(
messageId: ID! @rules(apply: ["required", "exists:messages,id,deletedAt,NULL"])
userId: ID! @rules(apply: ["required", "exists:users,id,deletedAt,NULL"])
reaction: String! @rules(apply: ["required", "max:255"])
): Reaction! @create @guard
removeReaction(
id: ID! @eq @rules(apply: ["required", "exists:reactions,id"])
): Reaction! @delete @guard
}MessageSent.php
<?php declare(strict_types=1);
namespace App\GraphQL\Subscriptions;
use GraphQL\Type\Definition\ResolveInfo;
use Illuminate\Http\Request;
use Nuwave\Lighthouse\Schema\Types\GraphQLSubscription;
use Nuwave\Lighthouse\Subscriptions\Subscriber;
use Nuwave\Lighthouse\Support\Contracts\GraphQLContext;
final class MessageSent extends GraphQLSubscription
{
/** Check if subscriber is allowed to listen to the subscription. */
public function authorize(Subscriber $subscriber, Request $request): bool
{
return true;
}
/** Filter which subscribers should receive the subscription. */
public function filter(Subscriber $subscriber, mixed $root): bool
{
return true;
}
}LIGHTHOUSE_SUBSCRIPTION_STORAGE=file
LIGHTHOUSE_SUBSCRIPTION_STORAGE_TTL=3600Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

