Initial Sample.
This commit is contained in:
34
graphql-subscription-express/index.html
Normal file
34
graphql-subscription-express/index.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<!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>
|
||||
Reference in New Issue
Block a user