Merged in feature/wrap-logging (pull request #2511)
Feature/wrap logging * feat: change all logging to go through our own logger function so that we can control log levels * move packages/trpc to using our own logger * merge Approved-by: Linus Flood
This commit is contained in:
@@ -3,6 +3,8 @@ import "server-only"
|
||||
import deepmerge from "deepmerge"
|
||||
import merge from "deepmerge"
|
||||
|
||||
import { createLogger } from "@scandic-hotels/common/logger/createLogger"
|
||||
|
||||
import { request } from "./request"
|
||||
|
||||
import type { CacheTime } from "@scandic-hotels/common/dataCache"
|
||||
@@ -18,6 +20,7 @@ export async function batchRequest<T>(
|
||||
}
|
||||
})[]
|
||||
): Promise<Data<T>> {
|
||||
const batchLogger = createLogger("graphql-batch-request")
|
||||
try {
|
||||
const response = await Promise.allSettled(
|
||||
queries.map((query) =>
|
||||
@@ -37,15 +40,14 @@ export async function batchRequest<T>(
|
||||
|
||||
if (reasons.length) {
|
||||
reasons.forEach((reason) => {
|
||||
console.error(`Batch request failed`, reason)
|
||||
batchLogger.error(`Batch request failed`, reason)
|
||||
})
|
||||
}
|
||||
|
||||
return { data }
|
||||
} catch (error) {
|
||||
console.error("Error in batched graphql request")
|
||||
console.error(error)
|
||||
throw new Error("Something went wrong")
|
||||
batchLogger.error("Error in batched graphql request", error)
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user