Skip to content
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

Support custom fetch option #493

Closed
nikithauc opened this issue Aug 3, 2021 · 0 comments
Closed

Support custom fetch option #493

nikithauc opened this issue Aug 3, 2021 · 0 comments

Comments

@nikithauc
Copy link
Contributor

nikithauc commented Aug 3, 2021

Thank you @alexrecuenco for suggesting this!

This whole module currently does not compile without the "dom" library, which should be avoided, you can import the fetch types from somewhere else alone without importing all the declarations from the dom. see ( Using /// in a .d.ts typescript declaration file has global effects microsoft/TypeScript#33901 )
Fetch as a global object as a requirement to run a library seems prone to errors.
For backward compatibility It would not be hard to add in the library a 'fetchObject' option, and if that isn't set, you try the global fetch, and if that doesn't exist, throw an error, instead of failing midway.
I have run into issues since our linters are not catching the non-existing global objects on a NodeJs application, and some Storage one had sneaked in for months. Trying to remove the sneaking DOM library references, I have now found that THIS library doesn't let me compile typescript without them, since it is referencing the dom library

#324 (comment)

As suggested above the approach would be:

  • Expose a customFetch option during the initialization of the Graph Client.
  • On creating the client object do the following:
    1.  if(!custom-fetch) || if(global-fetch)(throw error)
      
    2. While making requests, call `customFetch` if available else fallback on global fetch.  
    

AB#10470

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant