From f341433c8f3f48281174533c3ea72bcaa6d48909 Mon Sep 17 00:00:00 2001 From: saridsa2 Date: Thu, 19 Mar 2026 16:53:40 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20all=207=20GraphQL=20queries=20=E2=80=94?= =?UTF-8?q?=20correct=20field=20names=20and=20LINKS/PHONES=20subfields?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Leads: landingPage → { primaryLinkUrl }, remove duplicateOfLeadId Ads: adFormat → format, destinationUrl/previewUrl → { primaryLinkUrl } FollowUps: remove non-existent callId field LeadActivities: durationSeconds → durationSec All transforms updated to match query changes Co-Authored-By: Claude Opus 4.6 (1M context) --- src/lib/queries.ts | 14 +++++++------- src/lib/transforms.ts | 16 ++++++++-------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/lib/queries.ts b/src/lib/queries.ts index eb17225..62847fc 100644 --- a/src/lib/queries.ts +++ b/src/lib/queries.ts @@ -1,5 +1,5 @@ // GraphQL queries for platform entities -// Platform remaps some SDK field names — queries use platform names +// Platform remaps SDK field names — all LINKS/PHONES fields need subfield selection export const LEADS_QUERY = `{ leads(first: 100, orderBy: [{ createdAt: DescNullsLast }]) { edges { node { id name createdAt updatedAt @@ -7,8 +7,8 @@ export const LEADS_QUERY = `{ leads(first: 100, orderBy: [{ createdAt: DescNulls contactPhone { primaryPhoneNumber primaryPhoneCallingCode } contactEmail { primaryEmail } source status priority interestedService assignedAgent - utmSource utmMedium utmCampaign utmContent utmTerm landingPage referrerUrl - leadScore spamScore isSpam isDuplicate duplicateOfLeadId + utmSource utmMedium utmCampaign utmContent utmTerm landingPage { primaryLinkUrl } referrerUrl + leadScore spamScore isSpam isDuplicate firstContacted lastContacted contactAttempts convertedAt patientId campaignId aiSummary aiSuggestedAction @@ -26,8 +26,8 @@ export const CAMPAIGNS_QUERY = `{ campaigns(first: 50, orderBy: [{ createdAt: De export const ADS_QUERY = `{ ads(first: 100, orderBy: [{ createdAt: DescNullsLast }]) { edges { node { id name createdAt updatedAt - adName externalAdId status adFormat - headline adDescription destinationUrl previewUrl + adName externalAdId status format + headline adDescription destinationUrl { primaryLinkUrl } previewUrl { primaryLinkUrl } impressions clicks conversions spend { amountMicros currencyCode } campaignId @@ -37,14 +37,14 @@ export const FOLLOW_UPS_QUERY = `{ followUps(first: 50, orderBy: [{ scheduledAt: id name createdAt typeCustom status scheduledAt completedAt priority assignedAgent - patientId callId + patientId } } } }`; export const LEAD_ACTIVITIES_QUERY = `{ leadActivities(first: 200, orderBy: [{ occurredAt: DescNullsLast }]) { edges { node { id name createdAt activityType summary occurredAt performedBy previousValue newValue - channel durationSeconds outcome + channel durationSec outcome leadId } } } }`; diff --git a/src/lib/transforms.ts b/src/lib/transforms.ts index ac87854..2416bb5 100644 --- a/src/lib/transforms.ts +++ b/src/lib/transforms.ts @@ -1,5 +1,5 @@ // Transform platform GraphQL responses → frontend entity types -// Platform remaps some field names during sync +// Platform remaps field names during sync — this layer normalizes them import type { Lead, Campaign, Ad, FollowUp, LeadActivity, Call, Patient } from '@/types/entities'; @@ -31,13 +31,13 @@ export function transformLeads(data: any): Lead[] { utmCampaign: n.utmCampaign, utmContent: n.utmContent, utmTerm: n.utmTerm, - landingPageUrl: n.landingPage, + landingPageUrl: n.landingPage?.primaryLinkUrl ?? null, referrerUrl: n.referrerUrl, leadScore: n.leadScore, spamScore: n.spamScore ?? 0, isSpam: n.isSpam ?? false, isDuplicate: n.isDuplicate ?? false, - duplicateOfLeadId: n.duplicateOfLeadId, + duplicateOfLeadId: null, firstContactedAt: n.firstContacted, lastContactedAt: n.lastContacted, contactAttempts: n.contactAttempts ?? 0, @@ -82,11 +82,11 @@ export function transformAds(data: any): Ad[] { adName: n.adName ?? n.name, externalAdId: n.externalAdId, adStatus: n.status, - adFormat: n.adFormat, + adFormat: n.format, headline: n.headline, adDescription: n.adDescription, - destinationUrl: n.destinationUrl, - previewUrl: n.previewUrl, + destinationUrl: n.destinationUrl?.primaryLinkUrl ?? null, + previewUrl: n.previewUrl?.primaryLinkUrl ?? null, impressions: n.impressions ?? 0, clicks: n.clicks ?? 0, conversions: n.conversions ?? 0, @@ -106,7 +106,7 @@ export function transformFollowUps(data: any): FollowUp[] { priority: n.priority ?? 'NORMAL', assignedAgent: n.assignedAgent, patientId: n.patientId, - callId: n.callId, + callId: null, patientName: undefined, patientPhone: undefined, description: n.name, @@ -124,7 +124,7 @@ export function transformLeadActivities(data: any): LeadActivity[] { previousValue: n.previousValue, newValue: n.newValue, channel: n.channel, - durationSeconds: n.durationSeconds, + durationSeconds: n.durationSec ?? 0, outcome: n.outcome, activityNotes: null, leadId: n.leadId,