From 1a06f30542e86b542260615a1130190c9d7f77fc Mon Sep 17 00:00:00 2001 From: Ben Pankow Date: Wed, 27 Sep 2023 15:38:25 -0700 Subject: [PATCH] [gql] add id to resource, asset group gql objects (#16857) ## Summary Introduces an id field to external resource and asset group objects --------- Co-authored-by: Isaac Hellendag --- .../ui-core/src/graphql/schema.graphql | 2 ++ .../packages/ui-core/src/graphql/types.ts | 4 ++++ .../src/overview/OverviewResourcesRoot.tsx | 1 + .../types/OverviewResourcesRoot.types.ts | 1 + .../src/resources/WorkspaceResourcesRoot.tsx | 1 + .../types/WorkspaceResourcesRoot.types.ts | 1 + .../src/search/types/useGlobalSearch.types.ts | 8 +++++-- .../ui-core/src/search/useGlobalSearch.tsx | 2 ++ .../src/workspace/WorkspaceContext.tsx | 2 ++ .../workspace/types/WorkspaceContext.types.ts | 24 ++++++++++++------- .../dagster_graphql/schema/asset_graph.py | 1 + .../dagster_graphql/schema/external.py | 4 +++- .../dagster_graphql/schema/resources.py | 3 +++ 13 files changed, 43 insertions(+), 11 deletions(-) diff --git a/js_modules/dagster-ui/packages/ui-core/src/graphql/schema.graphql b/js_modules/dagster-ui/packages/ui-core/src/graphql/schema.graphql index 05f47038bab6c..fbe539f4c2641 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/graphql/schema.graphql +++ b/js_modules/dagster-ui/packages/ui-core/src/graphql/schema.graphql @@ -2022,11 +2022,13 @@ type Job implements SolidContainer & IPipelineSnapshot { } type AssetGroup { + id: String! groupName: String! assetKeys: [AssetKey!]! } type ResourceDetails { + id: String! name: String! description: String configFields: [ConfigTypeField!]! diff --git a/js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts b/js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts index a4362df6da093..29b8e4b1b193d 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts +++ b/js_modules/dagster-ui/packages/ui-core/src/graphql/types.ts @@ -246,6 +246,7 @@ export type AssetGroup = { __typename: 'AssetGroup'; assetKeys: Array; groupName: Scalars['String']; + id: Scalars['String']; }; export type AssetGroupSelector = { @@ -3198,6 +3199,7 @@ export type ResourceDetails = { configFields: Array; configuredValues: Array; description: Maybe; + id: Scalars['String']; isTopLevel: Scalars['Boolean']; jobsOpsUsing: Array; name: Scalars['String']; @@ -4727,6 +4729,7 @@ export const buildAssetGroup = ( __typename: 'AssetGroup', assetKeys: overrides && overrides.hasOwnProperty('assetKeys') ? overrides.assetKeys! : [], groupName: overrides && overrides.hasOwnProperty('groupName') ? overrides.groupName! : 'aut', + id: overrides && overrides.hasOwnProperty('id') ? overrides.id! : 'eligendi', }; }; @@ -10279,6 +10282,7 @@ export const buildResourceDetails = ( overrides && overrides.hasOwnProperty('configuredValues') ? overrides.configuredValues! : [], description: overrides && overrides.hasOwnProperty('description') ? overrides.description! : 'laudantium', + id: overrides && overrides.hasOwnProperty('id') ? overrides.id! : 'quia', isTopLevel: overrides && overrides.hasOwnProperty('isTopLevel') ? overrides.isTopLevel! : false, jobsOpsUsing: overrides && overrides.hasOwnProperty('jobsOpsUsing') ? overrides.jobsOpsUsing! : [], diff --git a/js_modules/dagster-ui/packages/ui-core/src/overview/OverviewResourcesRoot.tsx b/js_modules/dagster-ui/packages/ui-core/src/overview/OverviewResourcesRoot.tsx index 955bf2dbd5544..38af325f70d14 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/overview/OverviewResourcesRoot.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/overview/OverviewResourcesRoot.tsx @@ -220,6 +220,7 @@ const OVERVIEW_RESOURCES_QUERY = gql` id name allTopLevelResourceDetails { + id ...ResourceEntryFragment } } diff --git a/js_modules/dagster-ui/packages/ui-core/src/overview/types/OverviewResourcesRoot.types.ts b/js_modules/dagster-ui/packages/ui-core/src/overview/types/OverviewResourcesRoot.types.ts index 4fc2c817b7f50..a6fd40d4381a4 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/overview/types/OverviewResourcesRoot.types.ts +++ b/js_modules/dagster-ui/packages/ui-core/src/overview/types/OverviewResourcesRoot.types.ts @@ -44,6 +44,7 @@ export type OverviewResourcesQuery = { name: string; allTopLevelResourceDetails: Array<{ __typename: 'ResourceDetails'; + id: string; name: string; description: string | null; resourceType: string; diff --git a/js_modules/dagster-ui/packages/ui-core/src/resources/WorkspaceResourcesRoot.tsx b/js_modules/dagster-ui/packages/ui-core/src/resources/WorkspaceResourcesRoot.tsx index 3eec9fd10e3e6..5da1a547b7fac 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/resources/WorkspaceResourcesRoot.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/resources/WorkspaceResourcesRoot.tsx @@ -152,6 +152,7 @@ const WORKSPACE_RESOURCES_QUERY = gql` id name allTopLevelResourceDetails { + id ...ResourceEntryFragment } } diff --git a/js_modules/dagster-ui/packages/ui-core/src/resources/types/WorkspaceResourcesRoot.types.ts b/js_modules/dagster-ui/packages/ui-core/src/resources/types/WorkspaceResourcesRoot.types.ts index 8e24bd27ae8d4..d9b989bfdb74f 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/resources/types/WorkspaceResourcesRoot.types.ts +++ b/js_modules/dagster-ui/packages/ui-core/src/resources/types/WorkspaceResourcesRoot.types.ts @@ -37,6 +37,7 @@ export type WorkspaceResourcesQuery = { name: string; allTopLevelResourceDetails: Array<{ __typename: 'ResourceDetails'; + id: string; name: string; description: string | null; resourceType: string; diff --git a/js_modules/dagster-ui/packages/ui-core/src/search/types/useGlobalSearch.types.ts b/js_modules/dagster-ui/packages/ui-core/src/search/types/useGlobalSearch.types.ts index 569758ce727f5..5dbb2decc1907 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/search/types/useGlobalSearch.types.ts +++ b/js_modules/dagster-ui/packages/ui-core/src/search/types/useGlobalSearch.types.ts @@ -33,7 +33,7 @@ export type SearchPrimaryQuery = { __typename: 'Repository'; id: string; name: string; - assetGroups: Array<{__typename: 'AssetGroup'; groupName: string}>; + assetGroups: Array<{__typename: 'AssetGroup'; id: string; groupName: string}>; pipelines: Array<{ __typename: 'Pipeline'; id: string; @@ -48,7 +48,11 @@ export type SearchPrimaryQuery = { name: string; pipelineName: string; }>; - allTopLevelResourceDetails: Array<{__typename: 'ResourceDetails'; name: string}>; + allTopLevelResourceDetails: Array<{ + __typename: 'ResourceDetails'; + id: string; + name: string; + }>; }>; } | null; diff --git a/js_modules/dagster-ui/packages/ui-core/src/search/useGlobalSearch.tsx b/js_modules/dagster-ui/packages/ui-core/src/search/useGlobalSearch.tsx index bfaed616c974e..5bd03b11e2fb9 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/search/useGlobalSearch.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/search/useGlobalSearch.tsx @@ -246,6 +246,7 @@ export const SEARCH_PRIMARY_QUERY = gql` id name assetGroups { + id groupName } pipelines { @@ -267,6 +268,7 @@ export const SEARCH_PRIMARY_QUERY = gql` pipelineName } allTopLevelResourceDetails { + id name } } diff --git a/js_modules/dagster-ui/packages/ui-core/src/workspace/WorkspaceContext.tsx b/js_modules/dagster-ui/packages/ui-core/src/workspace/WorkspaceContext.tsx index c778ae3818863..953f39b8e1f6b 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/workspace/WorkspaceContext.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/workspace/WorkspaceContext.tsx @@ -130,9 +130,11 @@ export const ROOT_WORKSPACE_QUERY = gql` pipelineName } assetGroups { + id groupName } allTopLevelResourceDetails { + id name } ...RepositoryInfoFragment diff --git a/js_modules/dagster-ui/packages/ui-core/src/workspace/types/WorkspaceContext.types.ts b/js_modules/dagster-ui/packages/ui-core/src/workspace/types/WorkspaceContext.types.ts index 44735b2621447..358edbfe12c59 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/workspace/types/WorkspaceContext.types.ts +++ b/js_modules/dagster-ui/packages/ui-core/src/workspace/types/WorkspaceContext.types.ts @@ -99,8 +99,12 @@ export type RootWorkspaceQuery = { mode: string; pipelineName: string; }>; - assetGroups: Array<{__typename: 'AssetGroup'; groupName: string}>; - allTopLevelResourceDetails: Array<{__typename: 'ResourceDetails'; name: string}>; + assetGroups: Array<{__typename: 'AssetGroup'; id: string; groupName: string}>; + allTopLevelResourceDetails: Array<{ + __typename: 'ResourceDetails'; + id: string; + name: string; + }>; location: {__typename: 'RepositoryLocation'; id: string; name: string}; displayMetadata: Array<{ __typename: 'RepositoryMetadata'; @@ -189,8 +193,12 @@ export type WorkspaceLocationNodeFragment = { mode: string; pipelineName: string; }>; - assetGroups: Array<{__typename: 'AssetGroup'; groupName: string}>; - allTopLevelResourceDetails: Array<{__typename: 'ResourceDetails'; name: string}>; + assetGroups: Array<{__typename: 'AssetGroup'; id: string; groupName: string}>; + allTopLevelResourceDetails: Array<{ + __typename: 'ResourceDetails'; + id: string; + name: string; + }>; location: {__typename: 'RepositoryLocation'; id: string; name: string}; displayMetadata: Array<{__typename: 'RepositoryMetadata'; key: string; value: string}>; }>; @@ -261,8 +269,8 @@ export type WorkspaceLocationFragment = { mode: string; pipelineName: string; }>; - assetGroups: Array<{__typename: 'AssetGroup'; groupName: string}>; - allTopLevelResourceDetails: Array<{__typename: 'ResourceDetails'; name: string}>; + assetGroups: Array<{__typename: 'AssetGroup'; id: string; groupName: string}>; + allTopLevelResourceDetails: Array<{__typename: 'ResourceDetails'; id: string; name: string}>; location: {__typename: 'RepositoryLocation'; id: string; name: string}; displayMetadata: Array<{__typename: 'RepositoryMetadata'; key: string; value: string}>; }>; @@ -314,8 +322,8 @@ export type WorkspaceRepositoryFragment = { mode: string; pipelineName: string; }>; - assetGroups: Array<{__typename: 'AssetGroup'; groupName: string}>; - allTopLevelResourceDetails: Array<{__typename: 'ResourceDetails'; name: string}>; + assetGroups: Array<{__typename: 'AssetGroup'; id: string; groupName: string}>; + allTopLevelResourceDetails: Array<{__typename: 'ResourceDetails'; id: string; name: string}>; location: {__typename: 'RepositoryLocation'; id: string; name: string}; displayMetadata: Array<{__typename: 'RepositoryMetadata'; key: string; value: string}>; }; diff --git a/python_modules/dagster-graphql/dagster_graphql/schema/asset_graph.py b/python_modules/dagster-graphql/dagster_graphql/schema/asset_graph.py index 0a980ed85e45b..f1b06b254d19f 100644 --- a/python_modules/dagster-graphql/dagster_graphql/schema/asset_graph.py +++ b/python_modules/dagster-graphql/dagster_graphql/schema/asset_graph.py @@ -1104,6 +1104,7 @@ def resolve_assetChecks(self, graphene_info: ResolveInfo) -> List[GrapheneAssetC class GrapheneAssetGroup(graphene.ObjectType): + id = graphene.NonNull(graphene.String) groupName = graphene.NonNull(graphene.String) assetKeys = non_null_list(GrapheneAssetKey) diff --git a/python_modules/dagster-graphql/dagster_graphql/schema/external.py b/python_modules/dagster-graphql/dagster_graphql/schema/external.py index db497dbf29c78..9e02e9bcbe25d 100644 --- a/python_modules/dagster-graphql/dagster_graphql/schema/external.py +++ b/python_modules/dagster-graphql/dagster_graphql/schema/external.py @@ -344,7 +344,9 @@ def resolve_assetGroups(self, _graphene_info: ResolveInfo): return [ GrapheneAssetGroup( - group_name, [external_node.asset_key for external_node in external_nodes] + f"{self._repository_location.name}-{self._repository.name}-{group_name}", + group_name, + [external_node.asset_key for external_node in external_nodes], ) for group_name, external_nodes in groups.items() ] diff --git a/python_modules/dagster-graphql/dagster_graphql/schema/resources.py b/python_modules/dagster-graphql/dagster_graphql/schema/resources.py index 23fdbdbec9887..2cf7d4b90085b 100644 --- a/python_modules/dagster-graphql/dagster_graphql/schema/resources.py +++ b/python_modules/dagster-graphql/dagster_graphql/schema/resources.py @@ -76,6 +76,7 @@ class Meta: class GrapheneResourceDetails(graphene.ObjectType): + id = graphene.NonNull(graphene.String) name = graphene.NonNull(graphene.String) description = graphene.String() configFields = graphene.Field( @@ -112,6 +113,8 @@ def __init__( ): super().__init__() + self.id = f"{location_name}-{repository_name}-{external_resource.name}" + self._location_name = check.str_param(location_name, "location_name") self._repository_name = check.str_param(repository_name, "repository_name")