async function upsertVideoComments (videoitems, graphId, conn) {
  const graph = new graphRequest.GraphBuilder().withGraphId(graphId)
  for (let i = 0; i < videoitems.length; i++) {
    const videoComment = {}
    const snippet = videoitems[i].snippet.topLevelComment.snippet
    videoComment.AuthorChannelURL__c = snippet.authorChannelUrl
    videoComment.AuthorImageURL__c = snippet.authorProfileImageUrl
    videoComment.Author_Name__c = snippet.authorDisplayName
    videoComment.CommentLikeCount__c = snippet.likeCount
    videoComment.CommentPublishedAt__c = snippet.publishedAt
    videoComment.CommentUpdatedAt__c = snippet.updatedAt
    videoComment.CommentText__c = snippet.textDisplay
    videoComment.Video__r = {}
    videoComment.Video__r.VideoId__c = snippet.videoId
    // compositeSubRequest
    const compositeSubRequest = new graphRequest.CompositeSubRequestBuilder()
      .withBody(videoComment)
      .withMethod('PATCH')
      .withReferenceId('comment' + i)
      .withUrl('/services/data/v51.0/sobjects/VideoComment__c/CommentId__c/' + videoitems[i].snippet.topLevelComment.id)
      .build()
    graph.addCompositeSubRequest(compositeSubRequest)
  }
  const graphCompositeRequest = graph.build()
  const graphApiInput = new graphRequest.CompositeGraphBuilder()
    .addGraph(graphCompositeRequest)
    .build()
  const resp = await conn.requestPost(
    '/services/data/v51.0/composite/graph',
    graphApiInput
  )
  return resp
}
// function to upsert video comments into Salesforce using Composite GraphAPI
function to upsert video comments into Salesforce using Composite GraphAPI
function to upsert video comments into Salesforce using Composite GraphAPI
async function upsertVideoComments (videoitems, graphId, conn) {
  const graph = new graphRequest.GraphBuilder().withGraphId(graphId)
  for (let i = 0; i < videoitems.length; i++) {
    const videoComment = {}
    const snippet = videoitems[i].snippet.topLevelComment.snippet
    videoComment.AuthorChannelURL__c = snippet.authorChannelUrl
    videoComment.AuthorImageURL__c = snippet.authorProfileImageUrl
    videoComment.Author_Name__c = snippet.authorDisplayName
    videoComment.CommentLikeCount__c = snippet.likeCount
    videoComment.CommentPublishedAt__c = snippet.publishedAt
    videoComment.CommentUpdatedAt__c = snippet.updatedAt
    videoComment.CommentText__c = snippet.textDisplay
    videoComment.Video__r = {}
    videoComment.Video__r.VideoId__c = snippet.videoId
    const compositeSubRequest = new graphRequest.CompositeSubRequestBuilder()
      .withBody(videoComment)
      .withMethod('PATCH')
      .withReferenceId('comment' + i)
      .withUrl('/services/data/v51.0/sobjects/VideoComment__c/CommentId__c/' + videoitems[i].snippet.topLevelComment.id)
      .build()
    graph.addCompositeSubRequest(compositeSubRequest)
  }
  const graphCompositeRequest = graph.build()
  const graphApiInput = new graphRequest.CompositeGraphBuilder()
    .addGraph(graphCompositeRequest)
    .build()
  const resp = await conn.requestPost(
    '/services/data/v51.0/composite/graph',
    graphApiInput
  )
  return resp
}
async function upsertVideoComments ( videoitems , graphId , conn ) { const graph = new graphRequest . GraphBuilder ( ) . withGraphId ( graphId ) for ( let i = 0 ; i < videoitems . length ; i ++ ) { const videoComment = { } const snippet = videoitems [ i ] . snippet . topLevelComment . snippet videoComment . AuthorChannelURL__c = snippet . authorChannelUrl videoComment . AuthorImageURL__c = snippet . authorProfileImageUrl videoComment . Author_Name__c = snippet . authorDisplayName videoComment . CommentLikeCount__c = snippet . likeCount videoComment . CommentPublishedAt__c = snippet . publishedAt videoComment . CommentUpdatedAt__c = snippet . updatedAt videoComment . CommentText__c = snippet . textDisplay videoComment . Video__r = { } videoComment . Video__r . VideoId__c = snippet . videoId const compositeSubRequest = new graphRequest . CompositeSubRequestBuilder ( ) . withBody ( videoComment ) . withMethod ( 'PATCH' ) . withReferenceId ( 'comment' + i ) . withUrl ( '/services/data/v51.0/sobjects/VideoComment__c/CommentId__c/' + videoitems [ i ] . snippet . topLevelComment . id ) . build ( ) graph . addCompositeSubRequest ( compositeSubRequest ) } const graphCompositeRequest = graph . build ( ) const graphApiInput = new graphRequest . CompositeGraphBuilder ( ) . addGraph ( graphCompositeRequest ) . build ( ) const resp = await conn . requestPost ( '/services/data/v51.0/composite/graph' , graphApiInput ) return resp }
function to upsert video comments into Salesforce using Composite GraphAPI
function to upsert video comments into Salesforce using Composite GraphAPI
// compositeSubRequest