// Skip authentication check if called from a server job (context.user will be undefined)
// We can detect if it's a server-side call by checking if context.entities exists but context.user doesn't
const isServerSideCall = !context.user && context.entities;
// Only check authentication for client-side calls
if (!context.user && !isServerSideCall) {
throw new HttpError(401, 'User not authenticated');
}
// Log the source of the call for debugging
if (isServerSideCall) {
console.log('getNewsArticles called from server-side job or process');
} else {
console.log(`getNewsArticles called by user: ${context.user?.id}`);
}
// Skip authentication check if called from a server job (context.user will be undefined)
// We can detect if it's a server-side call by checking if context.entities exists but context.user doesn't
const isServerSideCall = !context.user && context.entities;
// Only check authentication for client-side calls
if (!context.user && !isServerSideCall) {
throw new HttpError(401, 'User not authenticated');
}
// Log the source of the call for debugging
if (isServerSideCall) {
console.log('getNewsArticles called from server-side job or process');
} else {
console.log(`getNewsArticles called by user: ${context.user?.id}`);
}