File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
## Features
4
4
5
+ - Normalization for the subscriptions_endpoint_url in the ` graphiql_source ` .
6
+ (See [ #628 ] ( https://github.com/graphql-rust/juniper/pull/628 ) for more details)
7
+
5
8
- Support raw identifiers in field and argument names. (` #[object] ` macro)
6
9
7
10
- Most error types now implement ` std::error::Error ` :
Original file line number Diff line number Diff line change @@ -31,7 +31,23 @@ pub fn graphiql_source(
31
31
let fetcher_source = r#"
32
32
<script>
33
33
if (usingSubscriptions) {
34
- var subscriptionsClient = new window.SubscriptionsTransportWs.SubscriptionClient(GRAPHQL_SUBSCRIPTIONS_URL, { reconnect: true });
34
+ var subscriptionEndpoint = normalizeSubscriptionEndpoint(GRAPHQL_URL, GRAPHQL_SUBSCRIPTIONS_URL);
35
+ var subscriptionsClient = new window.SubscriptionsTransportWs.SubscriptionClient(subscriptionEndpoint, { reconnect: true });
36
+ }
37
+
38
+ function normalizeSubscriptionEndpoint(endpoint, subscriptionEndpoint) {
39
+ if (subscriptionEndpoint) {
40
+ if (subscriptionEndpoint.startsWith('/')) {
41
+ const secure =
42
+ endpoint.includes('https') || location.href.includes('https')
43
+ ? 's'
44
+ : ''
45
+ return `ws${secure}://${location.host}${subscriptionEndpoint}`
46
+ } else {
47
+ return subscriptionEndpoint.replace(/^http/, 'ws')
48
+ }
49
+ }
50
+ return null
35
51
}
36
52
37
53
function graphQLFetcher(params) {
You can’t perform that action at this time.
0 commit comments