Добавлены плагины для Apollo Server, обеспечивающие логирование операций GraphQL и обработку ошибок. Улучшено логирование в резолверах, добавлены проверки параметров с детальной информацией. Обновлены типы GraphQL для поддержки новых полей в деталях группы быстрого поиска.
This commit is contained in:
@ -86,6 +86,24 @@ const server = new ApolloServer({
|
||||
typeDefs,
|
||||
resolvers,
|
||||
introspection: true,
|
||||
plugins: [
|
||||
{
|
||||
async requestDidStart() {
|
||||
return {
|
||||
async didResolveOperation(requestContext: any) {
|
||||
console.log('🔍 GraphQL Operation:', {
|
||||
operationName: requestContext.request.operationName,
|
||||
query: requestContext.request.query?.replace(/\s+/g, ' ').substring(0, 200) + '...',
|
||||
variables: requestContext.request.variables
|
||||
});
|
||||
},
|
||||
async didEncounterErrors(requestContext: any) {
|
||||
console.error('❌ GraphQL Errors:', requestContext.errors);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
const handler = startServerAndCreateNextHandler(server, {
|
||||
|
@ -1819,24 +1819,52 @@ export const resolvers = {
|
||||
|
||||
laximoQuickDetail: async (_: unknown, { catalogCode, vehicleId, quickGroupId, ssd }: { catalogCode: string; vehicleId: string; quickGroupId: string; ssd: string }) => {
|
||||
try {
|
||||
console.log('🔍 Запрос деталей группы быстрого поиска:', {
|
||||
catalogCode,
|
||||
vehicleId,
|
||||
quickGroupId,
|
||||
console.log('🔍 Запрос деталей группы быстрого поиска - RAW PARAMS:', {
|
||||
catalogCode: catalogCode,
|
||||
catalogCodeType: typeof catalogCode,
|
||||
catalogCodeLength: catalogCode?.length,
|
||||
vehicleId: vehicleId,
|
||||
vehicleIdType: typeof vehicleId,
|
||||
vehicleIdLength: vehicleId?.length,
|
||||
quickGroupId: quickGroupId,
|
||||
quickGroupIdType: typeof quickGroupId,
|
||||
quickGroupIdLength: quickGroupId?.length,
|
||||
ssd: ssd ? `${ssd.substring(0, 30)}...` : 'отсутствует'
|
||||
ssd: ssd ? `${ssd.substring(0, 50)}...` : 'отсутствует',
|
||||
ssdType: typeof ssd,
|
||||
ssdLength: ssd?.length
|
||||
})
|
||||
|
||||
// Валидация параметров
|
||||
// Валидация параметров с детальными логами
|
||||
console.log('🔍 Проверка catalogCode:', { catalogCode, isEmpty: !catalogCode, isTrimEmpty: catalogCode?.trim() === '' })
|
||||
if (!catalogCode || catalogCode.trim() === '') {
|
||||
console.error('❌ Пустой catalogCode:', catalogCode)
|
||||
throw new Error(`Пустой код каталога: "${catalogCode}"`)
|
||||
}
|
||||
|
||||
console.log('🔍 Проверка vehicleId:', { vehicleId, isUndefined: vehicleId === undefined, isNull: vehicleId === null, isEmpty: vehicleId === '' })
|
||||
if (vehicleId === undefined || vehicleId === null) {
|
||||
console.error('❌ Пустой vehicleId:', vehicleId)
|
||||
throw new Error(`Пустой ID автомобиля: "${vehicleId}"`)
|
||||
}
|
||||
|
||||
console.log('🔍 Проверка quickGroupId:', { quickGroupId, isEmpty: !quickGroupId, isTrimEmpty: quickGroupId?.trim() === '' })
|
||||
if (!quickGroupId || quickGroupId.trim() === '') {
|
||||
console.error('❌ Пустой quickGroupId:', quickGroupId)
|
||||
throw new Error(`Пустой ID группы: "${quickGroupId}"`)
|
||||
}
|
||||
|
||||
return await laximoService.getListQuickDetail(catalogCode, vehicleId, quickGroupId, ssd)
|
||||
console.log('🔍 Проверка ssd:', { ssd: ssd ? `${ssd.substring(0, 30)}...` : ssd, isEmpty: !ssd, isTrimEmpty: ssd?.trim() === '' })
|
||||
if (!ssd || ssd.trim() === '') {
|
||||
console.error('❌ Пустой ssd:', ssd)
|
||||
throw new Error(`Пустой SSD: "${ssd}"`)
|
||||
}
|
||||
|
||||
console.log('✅ Все параметры валидны, вызываем laximoService.getListQuickDetail')
|
||||
const result = await laximoService.getListQuickDetail(catalogCode, vehicleId, quickGroupId, ssd)
|
||||
console.log('✅ Результат от laximoService:', result ? 'получен' : 'null')
|
||||
return result
|
||||
} catch (error) {
|
||||
console.error('Ошибка получения деталей группы быстрого поиска:', error)
|
||||
console.error('❌ Ошибка получения деталей группы быстрого поиска:', error)
|
||||
throw error // Пробрасываем ошибку наверх
|
||||
}
|
||||
},
|
||||
|
@ -1421,6 +1421,9 @@ export const typeDefs = gql`
|
||||
detailid: String!
|
||||
name: String!
|
||||
oem: String!
|
||||
formattedoem: String
|
||||
parttype: String
|
||||
filter: String
|
||||
brand: String
|
||||
description: String
|
||||
applicablemodels: String
|
||||
|
Reference in New Issue
Block a user