Skip to content

Commit d1d3bf4

Browse files
authored
Updates for Web Worker (f#60)
1 parent ef82b84 commit d1d3bf4

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

graphql.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@
3131
})
3232
}
3333

34+
var __doRequest
35+
3436
if (typeof XMLHttpRequest !== 'undefined') {
35-
function __doRequest(
37+
__doRequest = function (
3638
method, url, contentType, accept, headers, body, _onRequestError, callback
3739
) {
3840
var xhr = new XMLHttpRequest
@@ -52,7 +54,7 @@
5254
xhr.send(body)
5355
}
5456
} else if (typeof require === 'function') {
55-
function __doRequest(
57+
__doRequest = function (
5658
method, url, contentType, accept, headers, body, onRequestError, callback
5759
) {
5860
var http = require('http'), https = require('https'), URL = require('url'), uri = URL.parse(url)
@@ -318,7 +320,7 @@
318320
if (!requestOptions) requestOptions = {}
319321
if (!variables) variables = {}
320322
var fragmentedQuery = that.buildQuery(query, variables)
321-
headers = __extend((that.options.headers||{}), (requestOptions.headers||{}))
323+
var headers = __extend((that.options.headers||{}), (requestOptions.headers||{}))
322324

323325
return new Promise(function (resolve, reject) {
324326
__request(debug, that.options.method || "post", that.getUrl(), headers, {
@@ -504,7 +506,6 @@
504506
}
505507

506508
GraphQLClient.prototype.ql = function (strings) {
507-
var that = this
508509
fragments = Array.prototype.slice.call(arguments, 1)
509510
fragments = fragments.map(function (fragment) {
510511
if (typeof fragment == 'string') {
@@ -529,7 +530,7 @@
529530
} else {
530531
root.graphql = factory(root.GraphQLClient)
531532
}
532-
}(this, function () {
533+
}(this || self, function () {
533534
return GraphQLClient
534535
}))
535536
})()

0 commit comments

Comments
 (0)