fix(SW-663): Fixed caching issue by using new GraphQLClient for each request
This commit is contained in:
@@ -17,26 +17,19 @@ export async function request<T>(
|
||||
params?: RequestInit
|
||||
): Promise<Data<T>> {
|
||||
try {
|
||||
const previewHash = ContentstackLivePreview.hash
|
||||
client.setHeaders({
|
||||
access_token: env.CMS_ACCESS_TOKEN,
|
||||
"Content-Type": "application/json",
|
||||
...params?.headers,
|
||||
})
|
||||
|
||||
const previewHash = ContentstackLivePreview.hash
|
||||
if (previewHash) {
|
||||
client.setEndpoint(env.CMS_PREVIEW_URL)
|
||||
client.setHeader("preview_token", env.CMS_PREVIEW_TOKEN)
|
||||
client.setHeader("live_preview", previewHash)
|
||||
} else {
|
||||
if (params?.cache) {
|
||||
client.requestConfig.cache = params.cache
|
||||
}
|
||||
if (params?.headers) {
|
||||
client.requestConfig.headers = params.headers
|
||||
}
|
||||
if (params?.next) {
|
||||
client.requestConfig.next = params.next
|
||||
}
|
||||
client.requestConfig.cache = params?.cache
|
||||
client.requestConfig.next = params?.next
|
||||
|
||||
if (env.PRINT_QUERY) {
|
||||
const print = (await import("graphql/language/printer")).print
|
||||
|
||||
Reference in New Issue
Block a user