Skip to content

Commit b03e4fe

Browse files
committed
fix schema error handling
1 parent a04b83f commit b03e4fe

File tree

5 files changed

+71
-12
lines changed

5 files changed

+71
-12
lines changed

packages/graphql-playground-electron/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"homepage": "https://github.com/graphcool/graphql-playground",
55
"repository": "graphcool/graphql-playground",
66
"description": "GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration)",
7-
"version": "1.5.0-rc.2",
7+
"version": "1.5.0-rc.3",
88
"author": {
99
"name": "Graphcool",
1010
"email": "[email protected]",
@@ -97,7 +97,7 @@
9797
"graphql-config": "^1.2.1",
9898
"graphql-config-extension-graphcool": "1.0.6",
9999
"graphql-config-extension-prisma": "0.0.4",
100-
"graphql-playground-react": "1.5.0-beta.12",
100+
"graphql-playground-react": "1.5.2",
101101
"immutable": "4.0.0-rc.9",
102102
"js-yaml": "^3.10.0",
103103
"lodash.merge": "^4.6.0",

packages/graphql-playground-electron/src/renderer/components/App.tsx

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,14 @@ cd ${folderPath}; graphql playground`)
161161
'cwd',
162162
JSON.stringify({ cwd: configDir, id: remote.getCurrentWindow().id }),
163163
)
164-
this.setState({
164+
const state = {
165165
configString,
166166
configPath,
167167
config,
168168
folderName: path.basename(folderPath),
169-
} as State)
169+
}
170+
this.setState(state as State)
171+
this.serializeWorkspace(state)
170172
} catch (error) {
171173
alert(error)
172174
}
@@ -210,6 +212,12 @@ cd ${folderPath}; graphql playground`)
210212
window.addEventListener('keydown', this.handleKeyDown, true)
211213
this.consumeEvents()
212214
ipcRenderer.send('ready', '')
215+
if (!this.state.endpoint) {
216+
const workspace = this.deserializeWorkspace()
217+
if (workspace) {
218+
this.setState(workspace)
219+
}
220+
}
213221
}
214222

215223
consumeEvents() {
@@ -315,9 +323,33 @@ cd ${folderPath}; graphql playground`)
315323
platformToken,
316324
}
317325

326+
this.serializeWorkspace(state)
327+
318328
this.setState(state)
319329
}
320330

331+
serializeWorkspace(state) {
332+
localStorage.setItem(
333+
'graphql-playground-last-workspace',
334+
JSON.stringify(state),
335+
)
336+
}
337+
338+
deserializeWorkspace() {
339+
try {
340+
const lastWorkspace = localStorage.getItem(
341+
'graphql-playground-last-workspace',
342+
)
343+
if (lastWorkspace) {
344+
return JSON.parse(lastWorkspace)
345+
}
346+
} catch (e) {
347+
//
348+
}
349+
350+
return undefined
351+
}
352+
321353
configContainsEndpoints(config: GraphQLConfigData): boolean {
322354
if (
323355
Object.keys((config.extensions && config.extensions.endpoints) || {})

packages/graphql-playground-electron/yarn.lock

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1809,13 +1809,20 @@ code-point-at@^1.0.0:
18091809
version "1.1.0"
18101810
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
18111811

1812-
codemirror-graphql@0.6.12, codemirror-graphql@^0.6.11, codemirror-graphql@^0.6.12:
1812+
codemirror-graphql@^0.6.11, codemirror-graphql@^0.6.12:
18131813
version "0.6.12"
18141814
resolved "https://registry.yarnpkg.com/codemirror-graphql/-/codemirror-graphql-0.6.12.tgz#91a273fe5188857524a30221d06e645b4ca41f00"
18151815
dependencies:
18161816
graphql-language-service-interface "^1.0.16"
18171817
graphql-language-service-parser "^0.1.14"
18181818

1819+
"codemirror-graphql@git+ssh://[email protected]/timsuchanek/codemirror-graphql.git#details-fix":
1820+
version "0.6.12"
1821+
resolved "git+ssh://[email protected]/timsuchanek/codemirror-graphql.git#801ec32683c38d6dc0f8f7bc19014a111edc9ebd"
1822+
dependencies:
1823+
graphql-language-service-interface "^1.0.18"
1824+
graphql-language-service-parser "^1.0.18"
1825+
18191826
codemirror@^5.18.2, codemirror@^5.26.0, codemirror@^5.27.4:
18201827
version "5.33.0"
18211828
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.33.0.tgz#462ad9a6fe8d38b541a9536a3997e1ef93b40c6a"
@@ -3630,7 +3637,7 @@ graphql-import@^0.4.0:
36303637
graphql "^0.12.3"
36313638
lodash "^4.17.4"
36323639

3633-
graphql-language-service-interface@^1.0.16:
3640+
graphql-language-service-interface@^1.0.16, graphql-language-service-interface@^1.0.18:
36343641
version "1.0.18"
36353642
resolved "https://registry.yarnpkg.com/graphql-language-service-interface/-/graphql-language-service-interface-1.0.18.tgz#c0fc1ef72c6f6f4bf9042bd7a8a8a66e0772caa8"
36363643
dependencies:
@@ -3675,17 +3682,17 @@ [email protected]:
36753682
dependencies:
36763683
graphql-config "1.1.7"
36773684

3678-
3679-
version "1.5.0-beta.12"
3680-
resolved "https://registry.yarnpkg.com/graphql-playground-react/-/graphql-playground-react-1.5.0-beta.12.tgz#a22fb33c49903ceb388751741cacc18000210172"
3685+
3686+
version "1.5.2"
3687+
resolved "https://registry.yarnpkg.com/graphql-playground-react/-/graphql-playground-react-1.5.2.tgz#9dcc747cdeb5ff86290e396556dca8136f8eb980"
36813688
dependencies:
36823689
apollo-link "^1.0.7"
36833690
apollo-link-http "^1.3.2"
36843691
apollo-link-ws "^1.0.4"
36853692
calculate-size "^1.1.1"
36863693
classnames "^2.2.5"
36873694
codemirror "^5.27.4"
3688-
codemirror-graphql "0.6.12"
3695+
codemirror-graphql "git+ssh://[email protected]/timsuchanek/codemirror-graphql.git#details-fix"
36893696
copy-to-clipboard "^3.0.8"
36903697
cuid "^1.3.8"
36913698
graphcool-styles "0.2.7"
@@ -3712,6 +3719,7 @@ [email protected]:
37123719
react-display-name "^0.2.3"
37133720
react-dom "^16.2.0"
37143721
react-helmet "^5.2.0"
3722+
react-input-autosize "^2.2.1"
37153723
react-modal "^3.1.11"
37163724
react-redux "^5.0.6"
37173725
react-router-dom "^4.2.2"
@@ -6528,6 +6536,12 @@ react-helmet@^5.2.0:
65286536
prop-types "^15.5.4"
65296537
react-side-effect "^1.1.0"
65306538

6539+
react-input-autosize@^2.2.1:
6540+
version "2.2.1"
6541+
resolved "https://registry.yarnpkg.com/react-input-autosize/-/react-input-autosize-2.2.1.tgz#ec428fa15b1592994fb5f9aa15bb1eb6baf420f8"
6542+
dependencies:
6543+
prop-types "^15.5.8"
6544+
65316545
react-modal@^1.6.5:
65326546
version "1.9.7"
65336547
resolved "https://registry.yarnpkg.com/react-modal/-/react-modal-1.9.7.tgz#07ef56790b953e3b98ef1e2989e347983c72871d"
@@ -7663,6 +7677,18 @@ styled-components@^3.1.6:
76637677
postcss-load-plugins "^2.2.0"
76647678
styled-jsx "^0.5.7"
76657679

7680+
"styled-jsx-postcss@git+https://github.com/timsuchanek/styled-jsx-postcss.git#build3":
7681+
version "0.2.0"
7682+
uid "677ee0fb7f9138047a00e03c8c3e44adbb33cf2a"
7683+
resolved "git+https://github.com/timsuchanek/styled-jsx-postcss.git#677ee0fb7f9138047a00e03c8c3e44adbb33cf2a"
7684+
dependencies:
7685+
babel-traverse "^6.21.0"
7686+
babylon "^6.14.1"
7687+
deasync "^0.1.9"
7688+
postcss "^5.2.8"
7689+
postcss-load-plugins "^2.2.0"
7690+
styled-jsx "^0.5.7"
7691+
76667692
[email protected], styled-jsx@^2.2.1:
76677693
version "2.2.1"
76687694
resolved "https://registry.yarnpkg.com/styled-jsx/-/styled-jsx-2.2.1.tgz#8b38b9e53e5d9767e392595ab1afdc8426b3ba5d"

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.0",
3+
"version": "1.5.2",
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/Playground.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import {
2323
saveConfig,
2424
setTracingSupported,
2525
injectHeaders,
26+
schemaFetchingError,
27+
schemaFetchingSuccess,
2628
} from '../state/sessions/actions'
2729
import { setConfigString } from '../state/general/actions'
2830
import { initState } from '../state/workspace/actions'
@@ -44,7 +46,6 @@ import {
4446
import { Session } from '../state/sessions/reducers'
4547
import { getWorkspaceId } from './Playground/util/getWorkspaceId'
4648
import { getSettings, getSettingsString } from '../state/workspace/reducers'
47-
import { schemaFetchingError, schemaFetchingSuccess } from '../lib'
4849

4950
export interface Response {
5051
resultID: string

0 commit comments

Comments
 (0)