-
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
Make createNetworkInterface isomorphic #645
Comments
Is it enough to just document that people should install |
That would require me to pollute my global namespace with |
Apollo already does that for you on the client :] that's how the polyfill works, and one of the reasons we didn't include the polyfill on the server. I'd be open to replacing |
Related: #269 Perhaps you'd be interested in working on this? |
There is nothing wrong with using Libraries are not meant to polyfill anything. Only application can polyfill its environment. What you should be doing is simply adding isomorphic-fetch as a dependency and using it as a dependency, e.g. const fetch = require('isomorphic-fetch'); Frontend users, who are concerned with the bundle size and who are already using another fetch implementation, are able to to dedupe the dependency at the bundle step. I am happy to raise a PR if you are happy with this proposal. |
As far as I know isomorphic fetch still adds a globa symbol if you require it that way, but I'm definitely open to a PR to make that change. |
/me rolls up shirt sleeves |
Thanks for bringing this to my attention. I wasn't aware of it. As their own docs state:
– https://github.com/matthew-andrews/isomorphic-fetch I will raise a PR that utilises https://github.com/qubyte/fetch-ponyfill. |
Yeah, I guess the idea of a "polyfill" is that it reproduces the native functionality. In this case, when browsers support it, does the ponyfill work on Node? |
|
Agreed, would be great not to have to do |
How about something like this? const fetch = global.fetch || (typeof window === 'undefined'
? require('node-fetch')
: require('whatwg-fetch')); And adding |
In the meantime, would it just be enough to create a custom network interface that uses fetch ponyfill? |
This issue has been automatically closed because it has not had recent activity after being marked as stale. If you belive this issue is still a problem or should be reopened, please reopen it! Thank you for your contributions to Apollo Client! |
Currently apollo-client relies on the globally available `fetch` api which causes a number of problems. In the browser apollo-client uses a polyfill which "pollutes" the global scope. This is something a library should probably rather not do. This change is based on previous discussion and work done in apollographql#661 and apollographql#645.
Currently apollo-client relies on the globally available `fetch` api which causes a number of problems. In the browser apollo-client uses a polyfill which "pollutes" the global scope. This is something a library should probably rather not do. This change is based on previous discussion and work done in apollographql#661 and apollographql#645.
Currently apollo-client relies on the globally available `fetch` api which causes a number of problems. In the browser apollo-client uses a polyfill which "pollutes" the global scope. This is something a library should probably rather not do. This change is based on previous discussion and work done in apollographql#661 and apollographql#645.
Currently apollo-client relies on the globally available `fetch` api which causes a number of problems. In the browser apollo-client uses a polyfill which "pollutes" the global scope. This is something a library should probably rather not do. This change is based on previous discussion and work done in apollographql#661 and apollographql#645.
Currently apollo-client relies on the globally available `fetch` api which causes a number of problems. In the browser apollo-client uses a polyfill which "pollutes" the global scope. This is something a library should probably rather not do. This change is based on previous discussion and work done in apollographql#661 and apollographql#645.
Currently apollo-client relies on the globally available `fetch` api which causes a number of problems. In the browser apollo-client uses a polyfill which "pollutes" the global scope. This is something a library should probably rather not do. This change is based on previous discussion and work done in apollographql#661 and apollographql#645.
Currently apollo-client relies on the globally available `fetch` api which causes a number of problems. In the browser apollo-client uses a polyfill which "pollutes" the global scope. This is something a library should probably rather not do. This change is based on previous discussion and work done in apollographql#661 and apollographql#645.
Calling createNetworkInterface on the server produces an error:
The change required this to work would be simply replacing
whatwg-fetch
withisomorphic-fetch
.The text was updated successfully, but these errors were encountered: