f / graphql.js

A Simple and Isomorphic GraphQL Client for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

v0.6.3 cannot make requests from node (__doRequest is not a function)

pimterry opened this issue · comments

When making requests in node with 0.6.3, they always fail with:

TypeError: __doRequest is not a function
  at __request (node_modules/graphql.js/graphql.js:109:5)
  at .../node_modules/graphql.js/graphql.js:320:11

This worked fine in v0.6.2. I'm testing specifically with node 10.15.3, but I suspect all versions are affected.

It looks like this is happening because https://github.com/f/graphql.js/pull/38/files flipped the test to define __doRequest for node.js from:

typeof require == 'function'

to:

typeof require !== 'function'

See the resulting code here: https://github.com/f/graphql.js/blob/master/graphql.js#L54-L82

This is never true in node, and neither is the XMLHttpRequest test above, so __doRequest is always undefined, and no requests can ever be made.

Please upgrade to 0.6.5

Should use 0.6.1

We have the same error with 0.6.5 and create react app

this seems to be a scope issue. since __doRequest is declared in an if block, its scope is limited to that block, and it's not available where its called.