You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
813 B
35 lines
813 B
6 months ago
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
|
<title>GraphQL Subscription</title>
|
||
|
</head>
|
||
|
<body>
|
||
|
<h1>GraphQL Subscription Response</h1>
|
||
|
<div id="response"></div>
|
||
|
|
||
|
<script>
|
||
|
const ws = new WebSocket(`ws://${location.host}`);
|
||
|
|
||
|
ws.onmessage = (event) => {
|
||
|
const data = JSON.parse(event.data);
|
||
|
const responseDiv = document.getElementById('response');
|
||
|
responseDiv.innerHTML = JSON.stringify(data, null, 2);
|
||
|
};
|
||
|
|
||
|
ws.onopen = () => {
|
||
|
console.log('WebSocket connection opened');
|
||
|
};
|
||
|
|
||
|
ws.onclose = () => {
|
||
|
console.log('WebSocket connection closed');
|
||
|
};
|
||
|
|
||
|
ws.onerror = (error) => {
|
||
|
console.error('WebSocket error:', error);
|
||
|
};
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|