Skip to content

Commit 7968cd3

Browse files
committed
fix subscriptions url resolution
1 parent f28c9f4 commit 7968cd3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

packages/graphql-playground-react/src/components/PlaygroundWrapper.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class PlaygroundWrapper extends React.Component<
170170
}`
171171
}
172172

173-
return endpoint
173+
return endpoint.replace(/^http/, 'ws')
174174
}
175175

176176
componentWillReceiveProps(nextProps: PlaygroundWrapperProps & ReduxProps) {
@@ -253,7 +253,9 @@ class PlaygroundWrapper extends React.Component<
253253
activeEnv.projectName,
254254
)
255255
const endpoint = endpoints.endpoint
256-
const subscriptionEndpoint = endpoints.subscriptionEndpoint
256+
const subscriptionEndpoint =
257+
endpoints.subscriptionEndpoint ||
258+
this.normalizeSubscriptionUrl(endpoint, endpoints.subscriptionEndpoint)
257259
const headers = endpoints.headers
258260
this.setState({
259261
endpoint,

packages/graphql-playground-react/src/state/sessions/fetchingSagas.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ export const defaultLinkCreator = (
7474
return { link: httpLink }
7575
}
7676

77+
const finalSubscriptionsEndpoint = wsEndpoint || subscriptionEndpoint
78+
7779
const subscriptionClient = new SubscriptionClient(
78-
wsEndpoint || subscriptionEndpoint,
80+
finalSubscriptionsEndpoint,
7981
{
8082
timeout: 20000,
8183
lazy: true,

0 commit comments

Comments
 (0)