Update Spree SDK fetcher

This commit is contained in:
tniezg
2021-08-18 15:47:11 +02:00
parent 30c29f0da8
commit 3b3a181dac
4 changed files with 97 additions and 87 deletions

View File

@@ -11,7 +11,7 @@ import getSpreeSdkMethodFromEndpointPath from 'framework/spree/utils/getSpreeSdk
import { SpreeSdkVariables } from 'framework/spree/types'
import SpreeSdkMethodFromEndpointPathError from 'framework/spree/errors/SpreeSdkMethodFromEndpointPathError'
import { GraphQLFetcher, GraphQLFetcherResult } from '@commerce/api'
import createCreateFetchFetcher from '../../utils/createCreateFetchFetcher'
import createCustomizedFetchFetcher from '../../utils/createCustomizedFetchFetcher'
import fetch, { Request } from 'node-fetch'
const createApiFetch: (
@@ -22,10 +22,13 @@ const createApiFetch: (
const client = makeClient({
host: requireConfigValue('spreeApiHost') as string,
fetcherType: 'custom',
createFetcher: createCreateFetchFetcher({
fetch,
requestClass: Request,
}),
createFetcher: (fetcherOptions) => {
return createCustomizedFetchFetcher({
fetch,
requestConstructor: Request,
...fetcherOptions,
})
},
})
return async (url, queryData = {}, fetchOptions = {}) => {