Skip to content

Commit ead66e4

Browse files
committed
add graphcool extension to middlewares
1 parent 2272a07 commit ead66e4

File tree

13 files changed

+739
-23
lines changed

13 files changed

+739
-23
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
getGraphQLConfig,
1010
findGraphQLConfigFile,
1111
GraphQLConfigData,
12+
resolveEnvsInValues,
1213
} from 'graphql-config'
1314
import { createNewWindow } from './utils'
1415
import createStore from './createStore'
@@ -116,7 +117,10 @@ cd ${folderPath}; graphql playground`)
116117
}
117118

118119
const config = await patchEndpointsToConfig(
119-
getGraphQLConfig(path.dirname(configPath)).config,
120+
resolveEnvsInValues(
121+
getGraphQLConfig(path.dirname(configPath)).config,
122+
process.env,
123+
),
120124
path.dirname(configPath),
121125
)
122126

@@ -235,7 +239,7 @@ cd ${folderPath}; graphql playground`)
235239
? path.basename(path.dirname(configPath))
236240
: undefined
237241
config = await patchEndpointsToConfig(
238-
getGraphQLConfig(input.cwd).config,
242+
resolveEnvsInValues(getGraphQLConfig(input.cwd).config, input.env),
239243
input.cwd,
240244
)
241245
}
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
{
22
"name": "graphql-playground-html",
3-
"version": "1.3.6",
4-
"homepage": "https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-html",
5-
"description": "GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",
3+
"version": "1.3.7-alpha.2",
4+
"homepage":
5+
"https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-html",
6+
"description":
7+
"GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",
68
"contributors": [
79
"Tim Suchanek <[email protected]>",
810
"Johannes Schickling <[email protected]>",
@@ -11,19 +13,12 @@
1113
"repository": "http://github.com/graphcool/graphql-playground.git",
1214
"license": "SEE LICENSE IN LICENSE",
1315
"main": "dist/index.js",
14-
"files": [
15-
"dist"
16-
],
16+
"files": ["dist"],
1717
"scripts": {
1818
"build": "tsc",
1919
"prepublishOnly": "npm run build"
2020
},
21-
"keywords": [
22-
"graphql",
23-
"graphiql",
24-
"playground",
25-
"graphcool"
26-
],
21+
"keywords": ["graphql", "graphiql", "playground", "graphcool"],
2722
"devDependencies": {
2823
"@types/node": "^8.0.47",
2924
"typescript": "^2.6.1"
@@ -33,6 +28,7 @@
3328
"definition": "dist/index.d.ts"
3429
},
3530
"dependencies": {
36-
"graphql-config": "^1.0.9"
31+
"graphql-config": "^1.0.9",
32+
"graphql-config-extension-graphcool": "^0.0.1"
3733
}
3834
}

packages/graphql-playground-html/src/render-playground-page.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import {
44
getUsedEnvs,
55
getGraphQLConfig,
66
findGraphQLConfigFile,
7+
resolveEnvsInValues,
78
} from 'graphql-config'
9+
import { patchEndpointsToConfig } from 'graphql-config-extension-graphcool'
810

911
import getLoadingMarkup from './get-loading-markup'
1012

@@ -22,23 +24,32 @@ export interface RenderPageOptions extends MiddlewareOptions {
2224

2325
const loading = getLoadingMarkup()
2426

25-
export function renderPlaygroundPage(options: RenderPageOptions) {
26-
let config
27-
let configPath
28-
let configString
29-
let folderName
30-
let env
27+
let config
28+
let configPath
29+
let configString
30+
let folderName
31+
let env
32+
async function init() {
3133
try {
3234
config = getGraphQLConfig().config
35+
config = resolveEnvsInValues(config, process.env)
36+
config = await patchEndpointsToConfig(config, process.cwd())
3337
configPath = findGraphQLConfigFile(process.cwd())
3438
configString = fs.readFileSync(configPath, 'utf-8')
3539
folderName = path.basename(process.cwd())
3640
env = getUsedEnvs(config)
3741
} catch (e) {
38-
//
42+
/* tslint:disable-next-line */
43+
console.error(e)
3944
}
45+
}
46+
47+
init()
48+
49+
export function renderPlaygroundPage(options: RenderPageOptions) {
4050
const extendedOptions = {
4151
...options,
52+
config,
4253
configString,
4354
folderName,
4455
canSaveConfig: false,

0 commit comments

Comments
 (0)