//todo: don't want to do this for embedded items private async Task <IEnumerable <INodeWithOutgoingRelationships> > GetIncomingPreviewContentPickerRelationshipsWhenPublishing( IGraphReplicaSet graphReplicaSet, dynamic graphSyncPartContent, string contentItemId) { // we only need to recreate incoming relationships // if we're publishing and there isn't currently a published version if (graphReplicaSet.Name != GraphReplicaSetNames.Published || await _contentItemsService.HasExistingPublishedVersion(contentItemId)) { return(Enumerable.Empty <INodeWithOutgoingRelationships>()); } // allow sync is called concurrently for preview and published // so we could get the before or after incoming relationships // either should do, but perhaps we should do it serially to consistently fetch the _before_ incoming relationships? IGetIncomingContentPickerRelationshipsQuery getDraftRelationshipsQuery = _serviceProvider.GetRequiredService <IGetIncomingContentPickerRelationshipsQuery>(); getDraftRelationshipsQuery.NodeLabels = MergeNodeCommand.NodeLabels; getDraftRelationshipsQuery.IdPropertyName = MergeNodeCommand.IdPropertyName; getDraftRelationshipsQuery.IdPropertyValue = _syncNameProvider.GetNodeIdPropertyValue( graphSyncPartContent, _previewContentItemVersion); IEnumerable <INodeWithOutgoingRelationships?> incomingContentPickerRelationshipsOrDefault = await _graphCluster.Run(_previewContentItemVersion.GraphReplicaSetName, getDraftRelationshipsQuery); #pragma warning disable S1905 // Sonar needs updating to know about nullable references return(incomingContentPickerRelationshipsOrDefault .Where(n => n != null) .Cast <INodeWithOutgoingRelationships>()); #pragma warning restore S1905 }