Skip to content

Commit

Permalink
Fix errors on boot (#93)
Browse files Browse the repository at this point in the history
* Provide a proper dev environment

* If no endpoint is provided, graciously tell the user

* Provide more help
  • Loading branch information
gjtorikian authored Oct 23, 2017
1 parent d55ab37 commit a46b2b8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
28 changes: 26 additions & 2 deletions app/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,30 @@ 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 == "") {
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"){
Expand All @@ -169,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) {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 .",
Expand Down
6 changes: 3 additions & 3 deletions webpack/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = require('./make-webpack-config')({})


module.exports = require('./make-webpack-config')({
devtool: 'eval-source-map'
})

0 comments on commit a46b2b8

Please sign in to comment.