@@ -5,7 +5,11 @@ import { Icon, $v } from 'graphcool-styles'
5
5
import * as cx from 'classnames'
6
6
import { Playground as IPlayground } from 'graphql-playground/lib/components/Playground'
7
7
import Playground from 'graphql-playground'
8
- import { getGraphQLConfig , findGraphQLConfigFile } from 'graphql-config'
8
+ import {
9
+ getGraphQLConfig ,
10
+ findGraphQLConfigFile ,
11
+ GraphQLConfigData ,
12
+ } from 'graphql-config'
9
13
import { createNewWindow } from './utils'
10
14
import createStore from './createStore'
11
15
import InitialView from './InitialView/InitialView'
@@ -16,6 +20,7 @@ import * as os from 'os'
16
20
import * as yaml from 'js-yaml'
17
21
import * as findUp from 'find-up'
18
22
import * as queryString from 'query-string'
23
+ import { patchEndpointsToConfig } from 'graphql-config-extension-graphcool'
19
24
// import { PermissionSession } from 'graphql-playground/lib/types'
20
25
21
26
const { dialog } = remote
@@ -33,8 +38,10 @@ interface State {
33
38
platformToken ?: string
34
39
configString ?: string
35
40
configPath ?: string
41
+
36
42
folderName ?: string
37
43
env ?: any
44
+ config ?: GraphQLConfigData
38
45
}
39
46
40
47
const events : any [ ] = [ ]
@@ -93,7 +100,7 @@ export default class ElectronApp extends React.Component<{}, State> {
93
100
this . setState ( { endpoint } as State )
94
101
}
95
102
96
- handleSelectFolder = ( folderPath : string ) => {
103
+ handleSelectFolder = async ( folderPath : string ) => {
97
104
try {
98
105
// Get config from folderPath
99
106
const configPath = findGraphQLConfigFile ( folderPath )
@@ -108,9 +115,15 @@ Then open the graphql config with:
108
115
cd ${ folderPath } ; graphql playground` )
109
116
}
110
117
118
+ const config = await patchEndpointsToConfig (
119
+ getGraphQLConfig ( path . dirname ( configPath ) ) . config ,
120
+ path . dirname ( configPath ) ,
121
+ )
122
+
111
123
this . setState ( {
112
124
configString,
113
125
configPath,
126
+ config,
114
127
folderName : path . basename ( folderPath ) ,
115
128
} as State )
116
129
} catch ( error ) {
@@ -192,7 +205,7 @@ cd ${folderPath}; graphql playground`)
192
205
}
193
206
}
194
207
195
- handleUrl = ( event , url ) => {
208
+ handleUrl = async ( event , url ) => {
196
209
const cutIndex = url . indexOf ( '//' )
197
210
const query = url . slice ( cutIndex + 2 )
198
211
const input = queryString . parse ( query )
@@ -209,6 +222,7 @@ cd ${folderPath}; graphql playground`)
209
222
let folderName
210
223
let configPath
211
224
const platformToken = input . platformToken
225
+ let config
212
226
213
227
if ( input . cwd ) {
214
228
configPath = findUp . sync ( [ '.graphqlconfig' , '.graphqlconfig.yml' ] , {
@@ -220,13 +234,18 @@ cd ${folderPath}; graphql playground`)
220
234
folderName = configPath
221
235
? path . basename ( path . dirname ( configPath ) )
222
236
: undefined
237
+ config = await patchEndpointsToConfig (
238
+ getGraphQLConfig ( input . cwd ) . config ,
239
+ input . cwd ,
240
+ )
223
241
}
224
242
225
243
this . setState ( {
226
244
configString,
227
245
folderName,
228
246
env : input . env ,
229
247
endpoint,
248
+ config,
230
249
platformToken,
231
250
} )
232
251
}
@@ -403,6 +422,7 @@ cd ${folderPath}; graphql playground`)
403
422
openTooltipTheme,
404
423
platformToken,
405
424
configString,
425
+ config,
406
426
} = this . state
407
427
408
428
return (
@@ -447,6 +467,7 @@ cd ${folderPath}; graphql playground`)
447
467
isElectron = { true }
448
468
platformToken = { platformToken }
449
469
configString = { configString }
470
+ config = { config }
450
471
onSaveConfig = { this . saveConfig }
451
472
canSaveConfig = { true }
452
473
env = { this . state . env }
0 commit comments