Skip to content

Commit 273546c

Browse files
committed
add migration for old sessions
1 parent ff848cb commit 273546c

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

packages/graphql-playground/src/components/MiddlewareApp.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ function getParameterByName(name: string): string | null {
2929

3030
export interface Props {
3131
endpoint?: string
32+
endpointUrl?: string
3233
subscriptionEndpoint?: string
3334
setTitle?: boolean
3435
settings?: EditorSettings
@@ -91,7 +92,10 @@ class MiddlewareApp extends React.Component<Props, State> {
9192
const { activeEnv, projectName } = this.getInitialActiveEnv(config)
9293

9394
let endpoint =
94-
props.endpoint || getParameterByName('endpoint') || location.href
95+
props.endpoint ||
96+
props.endpointUrl ||
97+
getParameterByName('endpoint') ||
98+
location.href
9599

96100
let subscriptionEndpoint: string | undefined | null =
97101
props.subscriptionEndpoint || getParameterByName('subscriptionEndpoint')
@@ -100,6 +104,8 @@ class MiddlewareApp extends React.Component<Props, State> {
100104
const endpoints = getActiveEndpoints(config, activeEnv, projectName)
101105
endpoint = endpoints.endpoint
102106
subscriptionEndpoint = endpoints.subscriptionEndpoint
107+
} else {
108+
subscriptionEndpoint = this.getGraphcoolSubscriptionEndpoint(endpoint)
103109
}
104110

105111
this.state = {
@@ -121,6 +127,16 @@ class MiddlewareApp extends React.Component<Props, State> {
121127
}
122128
}
123129

130+
getGraphcoolSubscriptionEndpoint(endpoint) {
131+
if (endpoint.includes('api.graph.cool')) {
132+
return `wss://subscriptions.graph.cool/v1/${
133+
endpoint.split('/').slice(-1)[0]
134+
}`
135+
}
136+
137+
return endpoint
138+
}
139+
124140
migrateSettingsString(settingsString) {
125141
const replacementMap = {
126142
theme: 'editor.theme',

packages/graphql-playground/src/components/PlaygroundStorage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default class PlaygroundStorage {
2424
}
2525

2626
// migrate headers to new format
27-
private static runMigration(project, migrationEndpoint?: string) {
27+
private static runMigration(project, migrationEndpoint: string) {
2828
if (!project) {
2929
return project
3030
}
@@ -204,7 +204,7 @@ export default class PlaygroundStorage {
204204
date: new Date(item.date),
205205
}))
206206
}
207-
return PlaygroundStorage.runMigration(result)
207+
return PlaygroundStorage.runMigration(result, this.endpoint)
208208
}
209209

210210
private getExecutedQueryCount() {

0 commit comments

Comments
 (0)