-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
run apollo-client in node environment throws error. #3578
Comments
Thanks @forclan - this is actually working as designed, but it is definitely a bit confusing. Apollo Boost doesn't let you set a I've marked this as a bug though since |
@hwillson I'm happy to take that one. Just tell me, the current behaviour is expected (in the browser) but you're suggesting to add fetch as a param to ApolloBoost then should I somehow check if we're running it in the browser/node.js environment and only allow it on node.js env or just simply add fetch param regardless of environment? |
Sorry for the delay @mbaranovski - I meant add the |
I'will close the issue since code is merged. |
@hwillson Do we have to specify the fetch param? Can't we just use a global unfetch polyfill |
@borisyordanov |
Intended outcome:
execute normally in node environment.
Actual outcome:
throw error:
How to reproduce the issue:
execute:
Versions
"dependencies": {
"apollo-boost": "^0.1.8",
"graphql": "^0.13.2",
"graphql-tag": "^2.9.2",
"node-fetch": "^2.1.2",
"react-apollo": "^2.1.4"
},
"devDependencies": {
"@types/node-fetch": "^2.1.1"
}
code error
it seems that is a code error in apollo-boost.
in
apollo-boost/src/index.ts
,DefaultClient
call new HttpLink(xxx) to create a HttpLink:and
HttpLink
is defined inapollo-link-http
, which callscreateHttpLink
:in
createHttpLink
it will access fetch in param:fetch
does exists inlinkOptions
but exists inlinkOptions.fetchOptions
, sofetcher
is undefined ans callcheckFetcher(fetcher);
throws error.The text was updated successfully, but these errors were encountered: