Handle real-time streaming for subscriptions
masterGraphQLite does not manage the real-time transport layer (like WebSockets or Server-Sent Events) itself. Instead, it treats the subscription request as a way to initialize the subscription logic.
Recommended Pattern:
- Define the subscription method in your controller with
#[Subscription]and avoidreturn type. - Use the controller method to perform setup tasks (e.g., storing subscription details or establishing connections in a backend store).
- Use HTTP response headers to pass necessary metadata back to the client, such as a subscription ID or the URL of a dedicated streaming server (SSE/WebSocket) that the client should connect to.
This approach allows you to offload the long-running connection to a technology better suited for streaming, preventing the PHP process from being held open indefinitely.