Skip to content

Commit

Permalink
refactor(graphql): make graphqlengine easier to use (datahub-project#…
Browse files Browse the repository at this point in the history
  • Loading branch information
anshbansal authored and cccs-Dustin committed Feb 1, 2023
1 parent c1015f0 commit 36f2ba0
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -410,57 +410,41 @@ public class GmsGraphQLEngine {
*/
public final List<BrowsableEntityType<?, ?>> browsableTypes;

public GmsGraphQLEngine(final EntityClient entityClient, final GraphClient graphClient,
final UsageClient usageClient, final AnalyticsService analyticsService, final EntityService entityService,
final RecommendationsService recommendationsService, final StatefulTokenService statefulTokenService,
final TimeseriesAspectService timeseriesAspectService, final EntityRegistry entityRegistry,
final SecretService secretService, final NativeUserService nativeUserService,
final IngestionConfiguration ingestionConfiguration,
final AuthenticationConfiguration authenticationConfiguration,
final AuthorizationConfiguration authorizationConfiguration, final GitVersion gitVersion,
final TimelineService timelineService, final boolean supportsImpactAnalysis,
final VisualConfiguration visualConfiguration, final TelemetryConfiguration telemetryConfiguration,
final TestsConfiguration testsConfiguration, final DataHubConfiguration datahubConfiguration,
final ViewsConfiguration viewsConfiguration, final SiblingGraphService siblingGraphService,
final GroupService groupService, final RoleService roleService,
final InviteTokenService inviteTokenService, final PostService postService,
final ViewService viewService,
final SettingsService settingsService, final LineageService lineageService,
final FeatureFlags featureFlags) {

this.entityClient = entityClient;
this.graphClient = graphClient;
this.usageClient = usageClient;
this.siblingGraphService = siblingGraphService;

this.analyticsService = analyticsService;
this.entityService = entityService;
this.recommendationsService = recommendationsService;
this.statefulTokenService = statefulTokenService;
this.secretService = secretService;
this.entityRegistry = entityRegistry;
this.gitVersion = gitVersion;
this.supportsImpactAnalysis = supportsImpactAnalysis;
this.timeseriesAspectService = timeseriesAspectService;
this.timelineService = timelineService;
this.nativeUserService = nativeUserService;
this.groupService = groupService;
this.roleService = roleService;
this.inviteTokenService = inviteTokenService;
this.postService = postService;
this.viewService = viewService;
this.settingsService = settingsService;
this.lineageService = lineageService;

this.ingestionConfiguration = Objects.requireNonNull(ingestionConfiguration);
this.authenticationConfiguration = Objects.requireNonNull(authenticationConfiguration);
this.authorizationConfiguration = Objects.requireNonNull(authorizationConfiguration);
this.visualConfiguration = visualConfiguration;
this.telemetryConfiguration = telemetryConfiguration;
this.testsConfiguration = testsConfiguration;
this.datahubConfiguration = datahubConfiguration;
this.viewsConfiguration = viewsConfiguration;
this.featureFlags = featureFlags;
public GmsGraphQLEngine(final GmsGraphQLEngineArgs args) {

this.entityClient = args.entityClient;
this.graphClient = args.graphClient;
this.usageClient = args.usageClient;
this.siblingGraphService = args.siblingGraphService;

this.analyticsService = args.analyticsService;
this.entityService = args.entityService;
this.recommendationsService = args.recommendationsService;
this.statefulTokenService = args.statefulTokenService;
this.secretService = args.secretService;
this.entityRegistry = args.entityRegistry;
this.gitVersion = args.gitVersion;
this.supportsImpactAnalysis = args.supportsImpactAnalysis;
this.timeseriesAspectService = args.timeseriesAspectService;
this.timelineService = args.timelineService;
this.nativeUserService = args.nativeUserService;
this.groupService = args.groupService;
this.roleService = args.roleService;
this.inviteTokenService = args.inviteTokenService;
this.postService = args.postService;
this.viewService = args.viewService;
this.settingsService = args.settingsService;
this.lineageService = args.lineageService;

this.ingestionConfiguration = Objects.requireNonNull(args.ingestionConfiguration);
this.authenticationConfiguration = Objects.requireNonNull(args.authenticationConfiguration);
this.authorizationConfiguration = Objects.requireNonNull(args.authorizationConfiguration);
this.visualConfiguration = args.visualConfiguration;
this.telemetryConfiguration = args.telemetryConfiguration;
this.testsConfiguration = args.testsConfiguration;
this.datahubConfiguration = args.datahubConfiguration;
this.viewsConfiguration = args.viewsConfiguration;
this.featureFlags = args.featureFlags;

this.datasetType = new DatasetType(entityClient);
this.corpUserType = new CorpUserType(entityClient, featureFlags);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package com.linkedin.datahub.graphql;

import com.datahub.authentication.AuthenticationConfiguration;
import com.datahub.authentication.group.GroupService;
import com.datahub.authentication.invite.InviteTokenService;
import com.datahub.authentication.post.PostService;
import com.datahub.authentication.token.StatefulTokenService;
import com.datahub.authentication.user.NativeUserService;
import com.datahub.authorization.AuthorizationConfiguration;
import com.datahub.authorization.role.RoleService;
import com.linkedin.datahub.graphql.analytics.service.AnalyticsService;
import com.linkedin.datahub.graphql.featureflags.FeatureFlags;
import com.linkedin.entity.client.EntityClient;
import com.linkedin.metadata.config.DataHubConfiguration;
import com.linkedin.metadata.config.IngestionConfiguration;
import com.linkedin.metadata.config.TestsConfiguration;
import com.linkedin.metadata.config.ViewsConfiguration;
import com.linkedin.metadata.config.VisualConfiguration;
import com.linkedin.metadata.entity.EntityService;
import com.linkedin.metadata.graph.GraphClient;
import com.linkedin.metadata.graph.SiblingGraphService;
import com.linkedin.metadata.models.registry.EntityRegistry;
import com.linkedin.metadata.recommendation.RecommendationsService;
import com.linkedin.metadata.secret.SecretService;
import com.linkedin.metadata.service.LineageService;
import com.linkedin.metadata.service.SettingsService;
import com.linkedin.metadata.service.ViewService;
import com.linkedin.metadata.telemetry.TelemetryConfiguration;
import com.linkedin.metadata.timeline.TimelineService;
import com.linkedin.metadata.timeseries.TimeseriesAspectService;
import com.linkedin.metadata.version.GitVersion;
import com.linkedin.usage.UsageClient;
import lombok.Data;

@Data
public class GmsGraphQLEngineArgs {
EntityClient entityClient;
GraphClient graphClient;
UsageClient usageClient;
AnalyticsService analyticsService;
EntityService entityService;
RecommendationsService recommendationsService;
StatefulTokenService statefulTokenService;
TimeseriesAspectService timeseriesAspectService;
EntityRegistry entityRegistry;
SecretService secretService;
NativeUserService nativeUserService;
IngestionConfiguration ingestionConfiguration;
AuthenticationConfiguration authenticationConfiguration;
AuthorizationConfiguration authorizationConfiguration;
GitVersion gitVersion;
TimelineService timelineService;
boolean supportsImpactAnalysis;
VisualConfiguration visualConfiguration;
TelemetryConfiguration telemetryConfiguration;
TestsConfiguration testsConfiguration;
DataHubConfiguration datahubConfiguration;
ViewsConfiguration viewsConfiguration;
SiblingGraphService siblingGraphService;
GroupService groupService;
RoleService roleService;
InviteTokenService inviteTokenService;
PostService postService;
ViewService viewService;
SettingsService settingsService;
LineageService lineageService;
FeatureFlags featureFlags;

//any fork specific args should go below this line
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.datahub.authorization.role.RoleService;
import com.datahub.authentication.post.PostService;
import com.linkedin.datahub.graphql.GmsGraphQLEngine;
import com.linkedin.datahub.graphql.GmsGraphQLEngineArgs;
import com.linkedin.datahub.graphql.GraphQLEngine;
import com.linkedin.datahub.graphql.analytics.service.AnalyticsService;
import com.linkedin.metadata.client.JavaEntityClient;
Expand Down Expand Up @@ -150,73 +151,42 @@ public class GraphQLEngineFactory {
@Bean(name = "graphQLEngine")
@Nonnull
protected GraphQLEngine getInstance() {
GmsGraphQLEngineArgs args = new GmsGraphQLEngineArgs();
args.setEntityClient(_entityClient);
args.setGraphClient(_graphClient);
args.setUsageClient(_usageClient);
if (isAnalyticsEnabled) {
return new GmsGraphQLEngine(
_entityClient,
_graphClient,
_usageClient,
new AnalyticsService(elasticClient, indexConvention),
_entityService,
_recommendationsService,
_statefulTokenService,
_timeseriesAspectService,
_entityRegistry,
_secretService,
_nativeUserService,
_configProvider.getIngestion(),
_configProvider.getAuthentication(),
_configProvider.getAuthorization(),
_gitVersion,
_timelineService,
_graphService.supportsMultiHop(),
_configProvider.getVisualConfig(),
_configProvider.getTelemetry(),
_configProvider.getMetadataTests(),
_configProvider.getDatahub(),
_configProvider.getViews(),
_siblingGraphService,
_groupService,
_roleService,
_inviteTokenService,
_postService,
_viewService,
_settingsService,
_lineageService,
_configProvider.getFeatureFlags()
).builder().build();
args.setAnalyticsService(new AnalyticsService(elasticClient, indexConvention));
}
args.setEntityService(_entityService);
args.setRecommendationsService(_recommendationsService);
args.setStatefulTokenService(_statefulTokenService);
args.setTimeseriesAspectService(_timeseriesAspectService);
args.setEntityRegistry(_entityRegistry);
args.setSecretService(_secretService);
args.setNativeUserService(_nativeUserService);
args.setIngestionConfiguration(_configProvider.getIngestion());
args.setAuthenticationConfiguration(_configProvider.getAuthentication());
args.setAuthorizationConfiguration(_configProvider.getAuthorization());
args.setGitVersion(_gitVersion);
args.setTimelineService(_timelineService);
args.setSupportsImpactAnalysis(_graphService.supportsMultiHop());
args.setVisualConfiguration(_configProvider.getVisualConfig());
args.setTelemetryConfiguration(_configProvider.getTelemetry());
args.setTestsConfiguration(_configProvider.getMetadataTests());
args.setDatahubConfiguration(_configProvider.getDatahub());
args.setViewsConfiguration(_configProvider.getViews());
args.setSiblingGraphService(_siblingGraphService);
args.setGroupService(_groupService);
args.setRoleService(_roleService);
args.setInviteTokenService(_inviteTokenService);
args.setPostService(_postService);
args.setViewService(_viewService);
args.setSettingsService(_settingsService);
args.setLineageService(_lineageService);
args.setFeatureFlags(_configProvider.getFeatureFlags());
return new GmsGraphQLEngine(
_entityClient,
_graphClient,
_usageClient,
null,
_entityService,
_recommendationsService,
_statefulTokenService,
_timeseriesAspectService,
_entityRegistry,
_secretService,
_nativeUserService,
_configProvider.getIngestion(),
_configProvider.getAuthentication(),
_configProvider.getAuthorization(),
_gitVersion,
_timelineService,
_graphService.supportsMultiHop(),
_configProvider.getVisualConfig(),
_configProvider.getTelemetry(),
_configProvider.getMetadataTests(),
_configProvider.getDatahub(),
_configProvider.getViews(),
_siblingGraphService,
_groupService,
_roleService,
_inviteTokenService,
_postService,
_viewService,
_settingsService,
_lineageService,
_configProvider.getFeatureFlags()
args
).builder().build();
}
}

0 comments on commit 36f2ba0

Please sign in to comment.