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

Is "custom fetch" still possible? #493

Closed
anulman opened this issue Apr 2, 2023 · 2 comments
Closed

Is "custom fetch" still possible? #493

anulman opened this issue Apr 2, 2023 · 2 comments

Comments

@anulman
Copy link

anulman commented Apr 2, 2023

I was reviewing the source to see if I could use the "custom fetch" feature to somehow wrap Shopify's Admin GraphQL API with graphql-request, and noticed that the fetch param seems to be ignored vs. the created fetcher, below.

const makeRequest = async <T = unknown, V extends Variables = Variables>(params: {
url: string
query: string | string[]
variables?: V
headers?: Dom.RequestInit['headers']
operationName?: string
fetch: Fetch
method?: HTTPMethodInput
fetchOptions: Dom.RequestInit
middleware?: RequestMiddleware<V>
}): Promise<Response<T>> => {
const { query, variables, fetchOptions } = params
const fetcher = createHttpMethodFetcher(uppercase(params.method ?? `post`))
const isBatchingQuery = Array.isArray(params.query)
const response = await fetcher(params)
const result = await getResult(response, fetchOptions.jsonSerializer ?? defaultJsonSerializer)

I'm guessing L406 should be something like const fetcher = params.fetch ?? createHttpMethodFetcher(...);

@doronkopit5
Copy link

@anulman you can see here that in the end it uses the fetch param

@anulman
Copy link
Author

anulman commented Apr 4, 2023

you’re right! i ended up using it and had no issues; forgot to come back and close this. thank you, and sorry for the false alarm 😅

@anulman anulman closed this as completed Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants