From ff6820cec4a1d4cbcc139a73a05388ff2e420061 Mon Sep 17 00:00:00 2001 From: "Garen J. Torikian" Date: Mon, 23 Oct 2017 15:54:12 -0700 Subject: [PATCH 1/3] Provide a proper dev environment --- package.json | 1 + webpack/webpack.config.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 8442f66..341a7e9 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "scripts": { "dev-server": "webpack-dev-server --config webpack/webpack-dev-server.config.js --progress --colors --port 2992 --inline", "hot-dev-server": "webpack-dev-server --config webpack/webpack-hot-dev-server.config.js --hot --progress --colors --port 2992 --inline", + "build-dev": "webpack --config webpack/webpack.config.js --progress --profile --colors", "build": "webpack --config webpack/webpack.config.production.js --progress --profile --colors", "start": "electron .", "start-dev": "NODE_ENV=development electron .", diff --git a/webpack/webpack.config.js b/webpack/webpack.config.js index 73fa9e6..bdc2be8 100755 --- a/webpack/webpack.config.js +++ b/webpack/webpack.config.js @@ -1,3 +1,3 @@ -module.exports = require('./make-webpack-config')({}) - - +module.exports = require('./make-webpack-config')({ + devtool: 'eval-source-map' +}) From c723f8d55fcb64dce88fbd7468e855cd7bfe9af4 Mon Sep 17 00:00:00 2001 From: "Garen J. Torikian" Date: Mon, 23 Oct 2017 15:54:25 -0700 Subject: [PATCH 2/3] If no endpoint is provided, graciously tell the user --- app/components/App.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/components/App.js b/app/components/App.js index e10e0a0..6fa4045 100644 --- a/app/components/App.js +++ b/app/components/App.js @@ -156,6 +156,17 @@ export default class App extends React.Component { const { endpoint, method, headers } = this.getCurrentTab(); + if (endpoint == "") { + return Promise.resolve({ + "data" : null, + "errors": [ + { + "message": "Provide a URL to a GraphQL endpoint to start making queries to it!" + } + ] + }); + } + if (method == "get") { var url = endpoint; if (typeof graphQLParams['variables'] === "undefined"){ From a311733538320ec485083a69f47b6eab1a6e82eb Mon Sep 17 00:00:00 2001 From: "Garen J. Torikian" Date: Mon, 23 Oct 2017 15:54:12 -0700 Subject: [PATCH 3/3] Provide more help --- app/components/App.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/app/components/App.js b/app/components/App.js index 6fa4045..713a179 100644 --- a/app/components/App.js +++ b/app/components/App.js @@ -154,6 +154,15 @@ export default class App extends React.Component { 'Content-Type': 'application/json' }; + const error = { + "data" : null, + "errors": [ + { + "message": "I couldn't communicate with the GraphQL server at the provided URL. Is it correct?" + } + ] + }; + const { endpoint, method, headers } = this.getCurrentTab(); if (endpoint == "") { @@ -167,6 +176,8 @@ export default class App extends React.Component { }); } + + if (method == "get") { var url = endpoint; if (typeof graphQLParams['variables'] === "undefined"){ @@ -180,14 +191,16 @@ export default class App extends React.Component { credentials: 'include', headers: Object.assign({}, defaultHeaders, headers), body: null - }).then(response => response.json()); + }).then(response => response.json()) + .catch(reason => error); } return fetch(endpoint, { method: method, credentials: 'include', headers: Object.assign({}, defaultHeaders, headers), body: JSON.stringify(graphQLParams) - }).then(response => response.json()); + }).then(response => response.json()) + .catch(reason => error); } handleChange(field, eOrKey, e) {