Skip to content

Commit 4722ede

Browse files
committed
fix docs seralization
1 parent 569268b commit 4722ede

File tree

4 files changed

+25
-6
lines changed

4 files changed

+25
-6
lines changed

packages/graphql-playground-react/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "graphql-playground-react",
3-
"version": "1.5.8",
3+
"version": "1.5.9",
44
"main": "./lib/lib.js",
55
"typings": "./lib/lib.d.ts",
66
"description": "GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class GraphQLBinApp extends React.Component<Props & ReduxProps, State> {
9595
}
9696

9797
if (!res.data || res.data.session === null) {
98-
return this.props.history.push('/v2/new')
98+
location.href = `${location.origin}/v2/new`
9999
}
100100
const state = JSON.parse(res.data.session.session)
101101
this.props.injectState(state)

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,22 @@ export default class Root extends React.Component<{}, {}> {
88
<BrowserRouter>
99
<Switch>
1010
<Route path="/v2/:id" component={GraphQLBinApp} />
11-
<Redirect from="/" to="/v2/new" component={GraphQLBinApp} />
11+
<Redirect
12+
exact={true}
13+
from="/"
14+
to="/v2/new"
15+
component={GraphQLBinApp}
16+
/>
17+
<Route path="*" component={RedirectToOldPlayground} />
1218
</Switch>
1319
</BrowserRouter>
1420
)
1521
}
1622
}
23+
24+
const RedirectToOldPlayground = props => {
25+
location.href = `https://legacy.graphqlbin.com${location.pathname}${
26+
location.search
27+
}`
28+
return null
29+
}

packages/graphql-playground-react/src/state/docs/reducers.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { GraphQLField } from 'graphql'
2-
import { Map, List, Record } from 'immutable'
2+
import { Map, List, Record, set } from 'immutable'
33
import { handleActions } from 'redux-actions'
44
import { columnWidth } from '../../constants'
55

@@ -18,12 +18,18 @@ export interface DocsSessionState {
1818
readonly keyMove: boolean
1919
}
2020

21-
export const DocsSession = Record<DocsSessionState>({
21+
export class DocsSession extends Record({
2222
navStack: List([]),
2323
docsOpen: false,
2424
docsWidth: columnWidth,
2525
keyMove: false,
26-
})
26+
}) {
27+
toJSON() {
28+
const obj = this.toObject()
29+
// don't serialize navStack, as it could contain circular references in the type definitions
30+
return set(obj, 'navStack', List([]))
31+
}
32+
}
2733

2834
const defaultState: DocsState = Map({ '': new DocsSession() })
2935

0 commit comments

Comments
 (0)