Skip to content

Commit 8b17ab5

Browse files
committed
Merge branch 'master' of github.com:graphcool/graphql-playground
2 parents 2c8c127 + e500e0e commit 8b17ab5

File tree

12 files changed

+86
-22
lines changed

12 files changed

+86
-22
lines changed

packages/graphql-playground-electron/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"author": {
99
"name": "Graphcool",
1010
"email": "[email protected]",
11-
"url": "graph.cool"
11+
"url": "http://graph.cool"
1212
},
1313
"main": "lib/main.js",
1414
"build": {

packages/graphql-playground-electron/src/ElectronApp.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ cd ${folderPath}; graphql playground`)
144144
createNewWindow()
145145
}
146146

147+
openSettingsTab = () => {
148+
if (this.playground) {
149+
this.playground.openSettingsTab()
150+
}
151+
}
152+
147153
nextTab = () => {
148154
if (this.playground) {
149155
this.playground.nextTab()
@@ -177,7 +183,7 @@ cd ${folderPath}; graphql playground`)
177183
ipcRenderer.on('File', this.readFileMessage)
178184
ipcRenderer.on('OpenSelectedFile', this.readOpenSelectedFileMessage)
179185
ipcRenderer.on('OpenUrl', this.handleUrl)
180-
window.addEventListener('keydown', this.handleKeyDown)
186+
window.addEventListener('keydown', this.handleKeyDown, true)
181187
this.consumeEvents()
182188
ipcRenderer.send('ready', '')
183189
}
@@ -202,14 +208,13 @@ cd ${folderPath}; graphql playground`)
202208
this.readOpenSelectedFileMessage,
203209
)
204210
ipcRenderer.removeListener('OpenUrl', this.handleUrl)
205-
window.removeEventListener('keydown', this.handleKeyDown)
211+
window.removeEventListener('keydown', this.handleKeyDown, true)
206212
}
207213

208214
handleKeyDown = e => {
209215
if (e.key === '{' && e.metaKey) {
210216
this.prevTab()
211-
}
212-
if (e.key === '}' && e.metaKey) {
217+
} else if (e.key === '}' && e.metaKey) {
213218
this.nextTab()
214219
}
215220
}
@@ -419,6 +424,9 @@ cd ${folderPath}; graphql playground`)
419424
case 'Close':
420425
this.closeTab()
421426
break
427+
case 'Settings':
428+
this.openSettingsTab()
429+
break
422430
}
423431
}
424432

packages/graphql-playground-electron/src/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ const template: any = [
221221
// click: () => manuallyCheckForUpdates(),
222222
// },
223223
{ type: 'separator' },
224+
{
225+
label: 'Settings',
226+
accelerator: 'Command+,',
227+
click: () => send('Tab', 'Settings'),
228+
},
229+
{ type: 'separator' },
224230
{
225231
label: 'Quit',
226232
accelerator: 'Command+Q',

packages/graphql-playground/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
"lint-staged": "^4.0.2",
7373
"node-noop": "^1.0.0",
7474
"object-assign": "4.1.0",
75-
"polished": "^1.9.0",
7675
"postcss-cssnext": "^2.9.0",
7776
"postcss-flexbugs-fixes": "^3.2.0",
7877
"postcss-import": "^9.1.0",
@@ -120,6 +119,7 @@
120119
"graphql": "^0.10.5",
121120
"isomorphic-fetch": "^2.2.1",
122121
"js-yaml": "^3.10.0",
122+
"polished": "^1.9.0",
123123
"json-stable-stringify": "^1.0.1",
124124
"keycode": "^2.1.9",
125125
"lodash": "^4.17.4",

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,13 @@ export type Theme = 'dark' | 'light'
6565
export interface EditorSettings {
6666
['editor.theme']: Theme
6767
['editor.reuseHeaders']: boolean
68+
['tracing.hideTracingResponse']: boolean
6869
}
6970

7071
const defaultSettings = `{
7172
"editor.theme": "dark",
72-
"editor.reuseHeaders": true
73+
"editor.reuseHeaders": true,
74+
"tracing.hideTracingResponse": true
7375
}`
7476

7577
class MiddlewareApp extends React.Component<Props, State> {
@@ -136,16 +138,21 @@ class MiddlewareApp extends React.Component<Props, State> {
136138
}
137139

138140
migrateSettingsString(settingsString) {
141+
const defaultSettingsObject = JSON.parse(defaultSettings)
139142
const replacementMap = {
140143
theme: 'editor.theme',
141144
reuseHeaders: 'editor.reuseHeaders',
142145
}
146+
143147
try {
144148
const settings = JSON.parse(settingsString)
145149
return JSON.stringify(
146-
mapKeys(settings, (value, key) => {
147-
return replacementMap[key] || key
148-
}),
150+
{
151+
...defaultSettingsObject,
152+
...mapKeys(settings, (value, key) => {
153+
return replacementMap[key] || key
154+
}),
155+
},
149156
null,
150157
2,
151158
)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ export class Playground extends React.PureComponent<Props & DocsState, State> {
373373
reshare: this.state.changed,
374374
isSharingAuthorization: this.isSharingAuthorization(),
375375
}}
376+
settings={this.props.settings}
376377
/>
377378
)}
378379
</GraphiqlWrapper>

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export interface Props {
7575
disableAutofocus?: boolean
7676
disableResize?: boolean
7777
fixedEndpoint?: boolean
78+
shouldHideTracingResponse: boolean
7879

7980
disableAnimation?: boolean
8081
hideLineNumbers?: boolean
@@ -902,7 +903,9 @@ export class GraphQLEditor extends React.PureComponent<
902903
let extensions
903904
if (result.extensions) {
904905
extensions = result.extensions
905-
delete result.extensions
906+
if (this.props.shouldHideTracingResponse) {
907+
delete result.extensions.tracing
908+
}
906909
}
907910
let isSubscription = false
908911
if (result.isSubscription) {

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Session } from '../../types'
33
import GraphQLEditor from './GraphQLEditor'
44
import { SchemaFetcher } from './SchemaFetcher'
55
import { SharingProps } from '../Share'
6+
import { EditorSettings } from '../MiddlewareApp'
67

78
export interface Props {
89
session: Session
@@ -30,6 +31,7 @@ export interface Props {
3031
sharing?: SharingProps
3132
fixedEndpoint?: boolean
3233
endpoint: string
34+
settings: EditorSettings
3335
}
3436

3537
export default class GraphQLEditorSession extends React.PureComponent<
@@ -89,6 +91,7 @@ export default class GraphQLEditorSession extends React.PureComponent<
8991
onClickShare={this.handleClickShare}
9092
sharing={sharing}
9193
fixedEndpoint={fixedEndpoint}
94+
shouldHideTracingResponse={this.shouldHideTracingResponse()}
9295
/>
9396
)
9497
}
@@ -124,4 +127,8 @@ export default class GraphQLEditorSession extends React.PureComponent<
124127
private handleClickShare = () => {
125128
this.props.onClickShare(this.props.session.id)
126129
}
130+
131+
private shouldHideTracingResponse = (): boolean => {
132+
return this.props.settings['tracing.hideTracingResponse']
133+
}
127134
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ export class QueryEditor extends React.Component<Props, {}> {
147147
if (this.props.schema !== prevProps.schema) {
148148
this.editor.options.lint.schema = this.props.schema
149149
this.editor.options.hintOptions.schema = this.props.schema
150+
if (this.props.schema) {
151+
this.editor.options.hintOptions.schema.getType = type => {
152+
return type
153+
}
154+
}
150155
CodeMirror.signal(this.editor, 'change', this.editor)
151156
}
152157
if (

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ export default class Tab extends React.PureComponent<Props, State> {
6868
.tab:hover {
6969
@p: .bgDarkBlue;
7070
}
71+
.tab:hover :global(.close) {
72+
opacity: 1;
73+
}
7174
.light.tab:hover {
7275
background-color: #eeeff0;
7376
}
@@ -120,12 +123,19 @@ export default class Tab extends React.PureComponent<Props, State> {
120123
}
121124
122125
.close {
123-
@p: .ml10, .o50, .relative;
126+
@p: .ml10, .relative;
124127
top: 1px;
125128
height: 13px;
126129
width: 13px;
130+
opacity: 0;
131+
127132
&.active {
128133
@p: .o100;
134+
opacity: 1;
135+
}
136+
137+
&.hasCircle {
138+
opacity: 1;
129139
}
130140
}
131141
@@ -196,7 +206,11 @@ export default class Tab extends React.PureComponent<Props, State> {
196206
'New Tab'}
197207
</div>
198208
<div
199-
className={`close ${index === selectedSessionIndex && 'active'}`}
209+
className={`close${index === selectedSessionIndex ? ' active' : ''}${
210+
session.isFile && session.hasChanged && !this.state.overCross
211+
? ' hasCircle'
212+
: ''
213+
}`}
200214
onClick={this.handleCloseSession}
201215
onMouseEnter={this.handleMouseOverCross}
202216
onMouseLeave={this.handleMouseOutCross}

0 commit comments

Comments
 (0)