Make fetch implementation configurable #2008
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently apollo-client relies on the globally available
fetch
apiwhich 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
#661 and #645.
Checklist:
Comments:
I believe that the current state where apollo-client inserts a fetch-polyfill and thus modifies the global scope is a behavior that a library should not have. I would like to use
apollo-client
within another library myself and I do not want to pollute the globale scope of they sites who will use my library.The most straightforward change I can think of is allowing to optionally pass a
fetch
implementation as configuration option when creating the network interface.This PR still has some rough edges. My main concerns are:
fetch
a good variable name for the config option?any
which should of course be changed.I'm curious about your feedback and I'll be happy fix the open points in case there's a chance to get this merged.
More references: #1134, #1155