graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

customFetch type should allow for function to be passed in

Open kevinschaffter opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe.

I noticed that the type for CodegenConfig only allows for the string of a module to be passed in for customFetch when graphql-tools loader which is being used to resolve this property also allows for a function.

Describe the solution you'd like

Can we make customFetch a union of either string or a function that returns a promise?

customFetch?: string | ((query: RequestInfo, options: RequestInit) => Promise<Response>);

This would also make the expected inputs / outputs of this function more clear for developers regardless of type they use. I have a PR of this change locally with updated docs / tests.

Describe alternatives you've considered

No response

Is your feature request related to a problem? Please describe.

No response

kevinschaffter avatar Sep 10 '23 19:09 kevinschaffter

Having the same issue

jonsapple avatar Dec 21 '23 16:12 jonsapple