Skip to content

Commit 67f60e6

Browse files
committed
rename theme to editor.theme
1 parent a11c6b1 commit 67f60e6

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ export interface State {
6161

6262
export type Theme = 'dark' | 'light'
6363
export interface EditorSettings {
64-
theme: Theme
65-
reuseHeaders: boolean
64+
['editor.theme']: Theme
65+
['editor.reuseHeaders']: boolean
6666
}
6767

6868
const defaultSettings = `{
69-
"theme": "dark",
70-
"reuseHeaders": true
69+
"editor.theme": "dark",
70+
"editor.reuseHeaders": true
7171
}`
7272

7373
class MiddlewareApp extends React.Component<Props, State> {
@@ -223,7 +223,7 @@ class MiddlewareApp extends React.Component<Props, State> {
223223
<title>{this.getTitle()}</title>
224224
</Helmet>
225225
) : null
226-
const { theme } = this.state.settings
226+
const theme = this.state.settings['editor.theme']
227227

228228
return (
229229
<div>
@@ -237,7 +237,7 @@ class MiddlewareApp extends React.Component<Props, State> {
237237
<ProjectsSideNav
238238
config={this.state.config}
239239
folderName={this.props.folderName || 'GraphQL App'}
240-
theme={this.state.settings.theme}
240+
theme={theme}
241241
activeEnv={this.state.activeEnv}
242242
onSelectEnv={this.handleSelectEnv}
243243
onNewWorkspace={this.props.onNewWorkspace}
@@ -344,8 +344,9 @@ class MiddlewareApp extends React.Component<Props, State> {
344344
}
345345

346346
normalizeSettings(settings: EditorSettings) {
347-
if (settings.theme !== 'dark' && settings.theme !== 'light') {
348-
settings.theme = 'dark'
347+
const theme = settings['editor.theme']
348+
if (theme !== 'dark' && theme !== 'light') {
349+
settings['editor.theme'] = 'dark'
349350
}
350351

351352
return settings

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,8 @@ export class Playground extends React.PureComponent<Props & DocsState, State> {
282282
}
283283
render() {
284284
const { sessions, selectedSessionIndex } = this.state
285-
const { isEndpoint, settings: { theme } } = this.props
285+
const { isEndpoint } = this.props
286+
const theme = this.props.settings['editor.theme']
286287
const selectedEndpointUrl = isEndpoint ? location.href : this.getEndpoint()
287288
const isGraphcoolUrl = this.isGraphcoolUrl(selectedEndpointUrl)
288289

@@ -358,7 +359,7 @@ export class Playground extends React.PureComponent<Props & DocsState, State> {
358359
schemaFetcher={this.schemaFetcher}
359360
fixedEndpoint={this.props.fixedEndpoints}
360361
sharing={{
361-
localTheme: this.props.settings.theme,
362+
localTheme: this.props.settings['editor.theme'],
362363
onShare: this.share,
363364
onToggleHistory: this.toggleShareHistory,
364365
onToggleAllTabs: this.toggleShareAllTabs,
@@ -816,7 +817,7 @@ export class Playground extends React.PureComponent<Props & DocsState, State> {
816817
const currentActiveSession =
817818
this.state && this.state.sessions[this.state.selectedSessionIndex]
818819
const headers =
819-
this.props.settings.reuseHeaders && currentActiveSession
820+
this.props.settings['editor.reuseHeaders'] && currentActiveSession
820821
? currentActiveSession.headers
821822
: ''
822823
if (session) {
@@ -1014,11 +1015,13 @@ export class Playground extends React.PureComponent<Props & DocsState, State> {
10141015
jsonVariables =
10151016
headers && headers.trim() !== '' ? JSON.parse(headers) : undefined
10161017
} catch (error) {
1017-
throw new Error(`Headers are invalid JSON: ${error.message}.`)
1018+
/* tslint:disable-next-line */
1019+
console.error(`Headers are invalid JSON: ${error.message}.`)
10181020
}
10191021

10201022
if (typeof jsonVariables !== 'object') {
1021-
throw new Error('Headers are not a JSON object.')
1023+
/* tslint:disable-next-line */
1024+
console.error('Headers are not a JSON object.')
10221025
}
10231026

10241027
return jsonVariables

0 commit comments

Comments
 (0)