Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add subscription support to graphiql #69

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion graphcoolPlayground.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ add "&raw" to the end of the URL within a browser.
// options as 'endpoint' belong here
endpoint: {{ .Endpoint }},
subscriptionEndpoint: {{ .SubscriptionEndpoint }},
setTitle: {{ .SetTitle }}
setTitle: {{ .SetTitle }},
settings: { "schema.polling.enable":false }
})
})</script>
</body>
Expand Down
6 changes: 5 additions & 1 deletion graphiql.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ add "&raw" to the end of the URL within a browser.
<script src="//cdn.jsdelivr.net/fetch/0.9.0/fetch.min.js"></script>
<script src="//cdn.jsdelivr.net/react/15.4.2/react.min.js"></script>
<script src="//cdn.jsdelivr.net/react/15.4.2/react-dom.min.js"></script>
<script src="https://unpkg.com/subscriptions-transport-ws@0.5.4/browser/client.js"></script>
<script src="https://unpkg.com/graphiql-subscriptions-fetcher@0.0.2/browser/client.js"></script>
<script src="//cdn.jsdelivr.net/npm/graphiql@{{ .GraphiqlVersion }}/graphiql.min.js"></script>
</head>
<body>
Expand Down Expand Up @@ -184,10 +186,12 @@ add "&raw" to the end of the URL within a browser.
history.replaceState(null, null, locationQuery(parameters));
}

var subscriptionsClient = new SubscriptionsTransportWs.SubscriptionClient("ws://"+document.location.hostname+":"+ document.location.port+"/subscriptions", { reconnect: true });
var subscriptionsFetcher = GraphiQLSubscriptionsFetcher.graphQLFetcher(subscriptionsClient,graphQLFetcher);
// Render <GraphiQL /> into the body.
ReactDOM.render(
React.createElement(GraphiQL, {
fetcher: graphQLFetcher,
fetcher: subscriptionsFetcher,
onEditQuery: onEditQuery,
onEditVariables: onEditVariables,
onEditOperationName: onEditOperationName,
Expand Down