Skip to content

Commit

Permalink
Make graphqlconfig optional. Closes graphql#311
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Dec 4, 2017
1 parent 7d1e392 commit a6d9412
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 74 deletions.
2 changes: 1 addition & 1 deletion packages/graphql-playground-html/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-playground-html",
"version": "1.3.5",
"version": "1.3.6",
"homepage": "https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-html",
"description": "GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",
"contributors": [
Expand Down
26 changes: 20 additions & 6 deletions packages/graphql-playground-html/src/render-playground-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,36 @@ export interface RenderPageOptions extends MiddlewareOptions {
env?: any
}

const config = getGraphQLConfig().config
const configPath = findGraphQLConfigFile(process.cwd())
const configString = fs.readFileSync(configPath, 'utf-8')
const folderName = path.basename(process.cwd())
const env = getUsedEnvs(config)

const loading = getLoadingMarkup()

export function renderPlaygroundPage(options: RenderPageOptions) {
let config
let configPath
let configString
let folderName
let env
try {
config = getGraphQLConfig().config
configPath = findGraphQLConfigFile(process.cwd())
configString = fs.readFileSync(configPath, 'utf-8')
folderName = path.basename(process.cwd())
env = getUsedEnvs(config)
} catch (e) {
//
}
const extendedOptions = {
...options,
configString,
folderName,
canSaveConfig: false,
env,
}
if (!extendedOptions.endpoint && !extendedOptions.configString) {
/* tslint:disable-next-line */
console.warn(
`WARNING: You didn't provide an endpoint and don't have a .graphqlconfig. Make sure you have at least one of them.`,
)
}
return `
<!DOCTYPE html>
<html>
Expand Down
21 changes: 8 additions & 13 deletions packages/graphql-playground-middleware-express/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "graphql-playground-middleware-express",
"version": "1.3.5",
"homepage": "https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-middleware-express",
"description": "GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",
"version": "1.3.6",
"homepage":
"https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-middleware-express",
"description":
"GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",
"contributors": [
"Tim Suchanek <tim@graph.cool>",
"Johannes Schickling <johannes@graph.cool>",
Expand All @@ -11,19 +13,12 @@
"repository": "http://github.com/graphcool/graphql-playground.git",
"license": "SEE LICENSE IN LICENSE",
"main": "dist/index.js",
"files": [
"dist"
],
"files": ["dist"],
"scripts": {
"build": "tsc",
"prepublishOnly": "npm run build"
},
"keywords": [
"graphql",
"graphiql",
"playground",
"graphcool"
],
"keywords": ["graphql", "graphiql", "playground", "graphcool"],
"peerDependencies": {
"express": "^4.16.2"
},
Expand All @@ -32,7 +27,7 @@
"typescript": "^2.6.1"
},
"dependencies": {
"graphql-playground-html": "^1.3.5",
"graphql-playground-html": "^1.3.6",
"graphql-playground-middleware": "^1.2.1-beta.6"
},
"typings": "dist/index.d.ts",
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql-playground-middleware-express/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ graphql-config@^1.0.9:
minimatch "^3.0.4"
rimraf "^2.6.2"

graphql-playground-html@^1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/graphql-playground-html/-/graphql-playground-html-1.3.5.tgz#962ea7b39682e2285712feb481ff06ea560cf900"
graphql-playground-html@^1.3.6:
version "1.3.6"
resolved "https://registry.yarnpkg.com/graphql-playground-html/-/graphql-playground-html-1.3.6.tgz#3db97d5d7e7123cf62a86820b0be5d4b4092af4a"
dependencies:
graphql-config "^1.0.9"

Expand Down
22 changes: 8 additions & 14 deletions packages/graphql-playground-middleware-hapi/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "graphql-playground-middleware-hapi",
"version": "1.3.5",
"homepage": "https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-middleware-hapi",
"description": "GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",
"version": "1.3.6",
"homepage":
"https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-middleware-hapi",
"description":
"GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",
"contributors": [
"Tim Suchanek <tim@graph.cool>",
"Johannes Schickling <johannes@graph.cool>",
Expand All @@ -11,20 +13,12 @@
"repository": "http://github.com/graphcool/graphql-playground.git",
"license": "SEE LICENSE IN LICENSE",
"main": "dist/index.js",
"files": [
"dist"
],
"files": ["dist"],
"scripts": {
"build": "tsc",
"prepublishOnly": "npm run build"
},
"keywords": [
"graphql",
"graphiql",
"playground",
"graphcool",
"hapi"
],
"keywords": ["graphql", "graphiql", "playground", "graphcool", "hapi"],
"peerDependencies": {
"hapi": "^16.6.2"
},
Expand All @@ -37,7 +31,7 @@
"definition": "dist/index.d.ts"
},
"dependencies": {
"graphql-playground-html": "^1.3.5",
"graphql-playground-html": "^1.3.6",
"graphql-playground-middleware": "^1.2.1-beta.6"
}
}
6 changes: 3 additions & 3 deletions packages/graphql-playground-middleware-hapi/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ graphql-config@^1.0.9:
minimatch "^3.0.4"
rimraf "^2.6.2"

graphql-playground-html@^1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/graphql-playground-html/-/graphql-playground-html-1.3.5.tgz#962ea7b39682e2285712feb481ff06ea560cf900"
graphql-playground-html@^1.3.6:
version "1.3.6"
resolved "https://registry.yarnpkg.com/graphql-playground-html/-/graphql-playground-html-1.3.6.tgz#3db97d5d7e7123cf62a86820b0be5d4b4092af4a"
dependencies:
graphql-config "^1.0.9"

Expand Down
22 changes: 8 additions & 14 deletions packages/graphql-playground-middleware-koa/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "graphql-playground-middleware-koa",
"version": "1.3.5",
"homepage": "https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-middleware-koa",
"description": "GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",
"version": "1.3.6",
"homepage":
"https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-middleware-koa",
"description":
"GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",
"contributors": [
"Tim Suchanek <tim@graph.cool>",
"Johannes Schickling <johannes@graph.cool>",
Expand All @@ -11,20 +13,12 @@
"repository": "http://github.com/graphcool/graphql-playground.git",
"license": "SEE LICENSE IN LICENSE",
"main": "dist/index.js",
"files": [
"dist"
],
"files": ["dist"],
"scripts": {
"build": "tsc",
"prepublishOnly": "npm run build"
},
"keywords": [
"graphql",
"graphiql",
"playground",
"graphcool",
"koa"
],
"keywords": ["graphql", "graphiql", "playground", "graphcool", "koa"],
"peerDependencies": {
"koa": "^2.3.0"
},
Expand All @@ -37,7 +31,7 @@
"definition": "dist/index.d.ts"
},
"dependencies": {
"graphql-playground-html": "^1.3.5",
"graphql-playground-html": "^1.3.6",
"graphql-playground-middleware": "^1.2.1-beta.6",
"koa": "^2.4.1"
}
Expand Down
6 changes: 3 additions & 3 deletions packages/graphql-playground-middleware-koa/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ graphql-config@^1.0.9:
minimatch "^3.0.4"
rimraf "^2.6.2"

graphql-playground-html@^1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/graphql-playground-html/-/graphql-playground-html-1.3.5.tgz#962ea7b39682e2285712feb481ff06ea560cf900"
graphql-playground-html@^1.3.6:
version "1.3.6"
resolved "https://registry.yarnpkg.com/graphql-playground-html/-/graphql-playground-html-1.3.6.tgz#3db97d5d7e7123cf62a86820b0be5d4b4092af4a"
dependencies:
graphql-config "^1.0.9"

Expand Down
22 changes: 8 additions & 14 deletions packages/graphql-playground-middleware-lambda/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "graphql-playground-middleware-lambda",
"version": "1.3.5",
"homepage": "https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-middleware-lambada",
"description": "GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",
"version": "1.3.6",
"homepage":
"https://github.com/graphcool/graphql-playground/tree/master/packages/graphql-playground-middleware-lambada",
"description":
"GraphQL IDE for better development workflows (GraphQL Subscriptions, interactive docs & collaboration).",
"contributors": [
"Tim Suchanek <tim@graph.cool>",
"Johannes Schickling <johannes@graph.cool>",
Expand All @@ -11,20 +13,12 @@
"repository": "http://github.com/graphcool/graphql-playground.git",
"license": "SEE LICENSE IN LICENSE",
"main": "dist/index.js",
"files": [
"dist"
],
"files": ["dist"],
"scripts": {
"build": "tsc",
"prepublishOnly": "npm run build"
},
"keywords": [
"graphql",
"graphiql",
"playground",
"graphcool",
"lambada"
],
"keywords": ["graphql", "graphiql", "playground", "graphcool", "lambada"],
"peerDependencies": {
"aws-lambda": "^0.1.2"
},
Expand All @@ -37,7 +31,7 @@
"definition": "dist/index.d.ts"
},
"dependencies": {
"graphql-playground-html": "^1.3.5",
"graphql-playground-html": "^1.3.6",
"graphql-playground-middleware": "^1.2.1-beta.6"
}
}
6 changes: 3 additions & 3 deletions packages/graphql-playground-middleware-lambda/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ graphql-config@^1.0.9:
minimatch "^3.0.4"
rimraf "^2.6.2"

graphql-playground-html@^1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/graphql-playground-html/-/graphql-playground-html-1.3.5.tgz#962ea7b39682e2285712feb481ff06ea560cf900"
graphql-playground-html@^1.3.6:
version "1.3.6"
resolved "https://registry.yarnpkg.com/graphql-playground-html/-/graphql-playground-html-1.3.6.tgz#3db97d5d7e7123cf62a86820b0be5d4b4092af4a"
dependencies:
graphql-config "^1.0.9"

Expand Down

0 comments on commit a6d9412

Please sign in to comment.