graphql-http
Advanced tools
Comparing version 0.1.1 to 0.2.0
'use strict'; | ||
var url = require('url'); | ||
var fetchMock = require('fetch-mock'); | ||
@@ -66,2 +67,25 @@ | ||
}); | ||
pit('should work with onlyBody mutate', function () { | ||
fetchMock.post('*', { | ||
body: {data: {whatwhat: true}}, | ||
headers: { | ||
'Content-Type': 'application/json; charset=utf-8' | ||
} | ||
}); | ||
var client = GQL.GQLClient('https://example.com/gql'); | ||
return client.configure({onlyBody: true}) | ||
.mutate('mutation foo{bar(){baz}}') | ||
.then(function (result) { | ||
expect(result).toEqual({ | ||
data: {whatwhat: true} | ||
}); | ||
var request = fetchMock.lastCall(); | ||
expect(url.parse(request[0]).search).toBe(null); | ||
}); | ||
}); | ||
}); |
@@ -44,3 +44,7 @@ 'use strict'; | ||
var requestUrl = this.url + '?' + params; | ||
var requestUrl = this.options.onlyBody ? ( | ||
this.url | ||
) : ( | ||
this.url + '?' + params | ||
); | ||
@@ -47,0 +51,0 @@ var method = this.options.method.toLowerCase(); |
{ | ||
"name": "graphql-http", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "A GraphQL client for executing GraphQL queries over HTTP.", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -5,3 +5,8 @@ # graphql-http | ||
### DISCLAIMER | ||
This library is not suitable for production use. If you're looking for a client | ||
with similar functionality, see [Lokka](https://github.com/kadirahq/lokka). It | ||
has much more support and is much more robust. | ||
### Usage | ||
@@ -13,7 +18,9 @@ | ||
const client = GQLClient('http://localhost:3000', { | ||
// anything passed here is merged with | ||
// the options passed to fetch() | ||
credentials: true, | ||
headers: { | ||
'X-Requested-With': 'XMLHttpRequest' | ||
fetch: { | ||
// anything passed here is merged with | ||
// the options passed to fetch() | ||
credentials: true, | ||
headers: { | ||
'X-Requested-With': 'XMLHttpRequest' | ||
} | ||
} | ||
@@ -20,0 +27,0 @@ }); |
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
10757
234
61