Skip to content

Conversation

@SinanMtl
Copy link
Contributor

Problem

When I was imported graphql.js on Web Worker, I saw these error messages on console:

Uncaught TypeError: Cannot set property 'graphql' of undefined
  at Object.<anonymous> (graphql.js:524)
ReferenceError: headers is not defined
  at caller (graphql.js:321)
ReferenceError: __doRequest is not defined
  at __request (graphql.js:109)

Solutions

self added for callback context.

;(function (root, factory) {
  ...
}(this || self, function () {
  return GraphQLClient
}))

Added var keyword to headers variable.

GraphQLClient.prototype.createSenderFunction = function (debug) {
  ...
  var headers = ...
  ...
}

__doRequest has been changed like below:

var __doRequest
  ....

if (typeof XMLHttpRequest !== 'undefined') {
  __doRequest = function () {
    ....
  }
} else if (typeof require === 'function') {
  __doRequest = function () {
    ....
  }
}

@f f merged commit d1d3bf4 into f:master Dec 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants