graphql-helper
Advanced tools
Comparing version 0.0.8 to 0.0.9
@@ -108,3 +108,3 @@ 'use strict'; | ||
return request(queryString, variables).then(function (r) { | ||
return r.errors ? Promise.reject(r.errors) : Promise.resolve(r.data); | ||
return r.errors ? Promise.reject(r.errors) : r.data ? Promise.resolve(r.data) : Promise.reject([{ message: 'Request error' }]); | ||
}); | ||
@@ -148,3 +148,3 @@ }, { __GRAPHQL_QUERY__: true, | ||
}).then(function (r) { | ||
return r.errors ? Promise.reject(r.errors) : Promise.resolve(r.data.payload); | ||
return r.errors ? Promise.reject(r.errors) : r.data ? Promise.resolve(r.data.payload) : Promise.reject([{ message: 'Request error' }]); | ||
}); | ||
@@ -151,0 +151,0 @@ }, { __GRAPHQL_MUTATION__: true, |
{ | ||
"name": "graphql-helper", | ||
"version": "0.0.8", | ||
"version": "0.0.9", | ||
"description": "A simple helper library for making GraphQL queries. For browser usage, ensure that you have a Promise polyfill.", | ||
@@ -5,0 +5,0 @@ "main": "lib.js", |
17
src.js
@@ -100,4 +100,10 @@ /* @flow */ | ||
return operationDefinitions[name] = decorate | ||
( variables => request(queryString, variables) | ||
.then(r => r.errors ? Promise.reject(r.errors) : Promise.resolve(r.data)) | ||
( variables => | ||
request(queryString, variables) | ||
.then(r => r.errors | ||
? Promise.reject(r.errors) | ||
: r.data | ||
? Promise.resolve(r.data) | ||
: Promise.reject([{ message: 'Request error' }]) | ||
) | ||
, { __GRAPHQL_QUERY__: true | ||
@@ -148,3 +154,8 @@ , operationName: name | ||
} | ||
).then(r => r.errors ? Promise.reject(r.errors) : Promise.resolve(r.data.payload)) | ||
).then(r => r.errors | ||
? Promise.reject(r.errors) | ||
: r.data | ||
? Promise.resolve(r.data.payload) | ||
: Promise.reject([{ message: 'Request error' }]) | ||
) | ||
, { __GRAPHQL_MUTATION__: true | ||
@@ -151,0 +162,0 @@ , operationName: capitalized |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22616
440