Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ function highlightQuery (query, errors) {
return queryHighlight
}

module.exports = function (params) {
require('isomorphic-fetch')
module.exports = function (params, fetch) {
if (!fetch) fetch = require('isomorphic-fetch')
if (!params.url) throw new Error('Missing url parameter')

var headers = new Headers(params.headers || {})
Expand All @@ -41,17 +41,16 @@ module.exports = function (params) {
return {
query: function (query, variables, onResponse) {

var req = new Request(params.url, {
return fetch(params.url, {
method: 'POST',
body: JSON.stringify({
query: query,
variables: variables
}),
headers: headers,
credentials: params.credentials
credentials: params.credentials,
agent: params.agent
})

return fetch(req)
.then(function (res) {
onResponse && onResponse(req, res)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
"author": "",
"license": "ISC",
"dependencies": {
"isomorphic-fetch": "^2.2.1"
"isomorphic-fetch": "^3.0.0"
}
}