Comparing version 0.0.5 to 0.0.6
24
index.js
@@ -20,3 +20,5 @@ var fs = require('fs'); | ||
promise.then(createWriter(outputFileName)); | ||
promise | ||
.then(createWriter(outputFileName)) | ||
.catch(throwError); | ||
}; | ||
@@ -31,3 +33,4 @@ | ||
.then(toSchemaLanguage) | ||
.then(createWriter(outputFileName)); | ||
.then(createWriter(outputFileName)) | ||
.catch(throwError); | ||
@@ -46,4 +49,14 @@ function toSchemaLanguage(introspectionQueryResponse) { | ||
return fetch(endpointUrl, {method: 'POST', body: body, headers: headers}).then(toJson); | ||
return fetch(endpointUrl, {method: 'POST', body: body, headers: headers}) | ||
.then(checkStatus) | ||
.then(toJson); | ||
function checkStatus(response) { | ||
if (response.status !== 200) { | ||
return Promise.reject(response.statusText); | ||
} | ||
return response; | ||
} | ||
function toJson(response) { | ||
@@ -65,1 +78,6 @@ return response.json(); | ||
} | ||
function throwError(error) { | ||
console.error(error); | ||
process.exit(1); | ||
} |
{ | ||
"name": "gql-tools", | ||
"description": "GraphQL Tools for schema handling.", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"author": "Alberto Mijares <almilo@almilo.es>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
6035
98