-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(propagation): Add graphql API #11030
Merged
shirshanka
merged 2 commits into
datahub-project:master
from
shirshanka:docs-propagation-gql
Jul 30, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
.../src/main/java/com/linkedin/datahub/graphql/types/common/mappers/DocumentationMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.linkedin.datahub.graphql.types.common.mappers; | ||
|
||
import com.linkedin.common.urn.Urn; | ||
import com.linkedin.datahub.graphql.QueryContext; | ||
import com.linkedin.datahub.graphql.generated.DataHubConnection; | ||
import com.linkedin.datahub.graphql.generated.Documentation; | ||
import com.linkedin.datahub.graphql.generated.DocumentationAssociation; | ||
import com.linkedin.datahub.graphql.generated.EntityType; | ||
import com.linkedin.datahub.graphql.types.mappers.ModelMapper; | ||
import java.util.stream.Collectors; | ||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public class DocumentationMapper | ||
implements ModelMapper<com.linkedin.common.Documentation, Documentation> { | ||
|
||
public static final DocumentationMapper INSTANCE = new DocumentationMapper(); | ||
|
||
public static Documentation map( | ||
@Nullable final QueryContext context, | ||
@Nonnull final com.linkedin.common.Documentation metadata) { | ||
return INSTANCE.apply(context, metadata); | ||
} | ||
|
||
@Override | ||
public Documentation apply( | ||
@Nullable final QueryContext context, | ||
@Nonnull final com.linkedin.common.Documentation input) { | ||
final Documentation result = new Documentation(); | ||
result.setDocumentations( | ||
input.getDocumentations().stream() | ||
.map(docAssociation -> mapDocAssociation(context, docAssociation)) | ||
.collect(Collectors.toList())); | ||
return result; | ||
} | ||
|
||
private DocumentationAssociation mapDocAssociation( | ||
@Nullable final QueryContext context, | ||
@Nonnull final com.linkedin.common.DocumentationAssociation association) { | ||
final DocumentationAssociation result = new DocumentationAssociation(); | ||
result.setDocumentation(association.getDocumentation()); | ||
if (association.getAttribution() != null) { | ||
result.setAttribution(MetadataAttributionMapper.map(context, association.getAttribution())); | ||
} | ||
return result; | ||
} | ||
|
||
private DataHubConnection mapConnectionEntity(@Nonnull final Urn urn) { | ||
DataHubConnection connection = new DataHubConnection(); | ||
connection.setUrn(urn.toString()); | ||
connection.setType(EntityType.DATAHUB_CONNECTION); | ||
return connection; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...ain/java/com/linkedin/datahub/graphql/types/common/mappers/MetadataAttributionMapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.linkedin.datahub.graphql.types.common.mappers; | ||
|
||
import com.linkedin.datahub.graphql.QueryContext; | ||
import com.linkedin.datahub.graphql.generated.MetadataAttribution; | ||
import com.linkedin.datahub.graphql.types.mappers.ModelMapper; | ||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
public class MetadataAttributionMapper | ||
implements ModelMapper<com.linkedin.common.MetadataAttribution, MetadataAttribution> { | ||
|
||
public static final MetadataAttributionMapper INSTANCE = new MetadataAttributionMapper(); | ||
|
||
public static MetadataAttribution map( | ||
@Nullable final QueryContext context, | ||
@Nonnull final com.linkedin.common.MetadataAttribution metadata) { | ||
return INSTANCE.apply(context, metadata); | ||
} | ||
|
||
@Override | ||
public MetadataAttribution apply( | ||
@Nullable final QueryContext context, | ||
@Nonnull final com.linkedin.common.MetadataAttribution input) { | ||
final MetadataAttribution result = new MetadataAttribution(); | ||
result.setTime(input.getTime()); | ||
result.setActor(UrnToEntityMapper.map(context, input.getActor())); | ||
if (input.getSource() != null) { | ||
result.setSource(UrnToEntityMapper.map(context, input.getSource())); | ||
} | ||
if (input.getSourceDetail() != null) { | ||
result.setSourceDetail(StringMapMapper.map(context, input.getSourceDetail())); | ||
} | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
""" | ||
Object containing the documentation aspect for an entity | ||
""" | ||
type Documentation { | ||
""" | ||
Structured properties on this entity | ||
""" | ||
documentations: [DocumentationAssociation!]! | ||
} | ||
|
||
""" | ||
Object containing the documentation aspect for an entity | ||
""" | ||
type DocumentationAssociation { | ||
""" | ||
Structured properties on this entity | ||
""" | ||
documentation: String! | ||
|
||
""" | ||
Information about who, why, and how this metadata was applied | ||
""" | ||
attribution: MetadataAttribution | ||
} | ||
|
||
""" | ||
Information about who, why, and how this metadata was applied | ||
""" | ||
type MetadataAttribution { | ||
""" | ||
The time this metadata was applied | ||
""" | ||
time: Long! | ||
|
||
""" | ||
The actor responsible for this metadata application | ||
""" | ||
actor: Entity! | ||
|
||
""" | ||
The source of this metadata application. If propagated, this will be an action. | ||
""" | ||
source: Entity | ||
|
||
""" | ||
Extra details about how this metadata was applied | ||
""" | ||
sourceDetail: [StringMapEntry!] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one thing that's missing is adding the new
common.graphql
file on the backend to our docs website auto-generation list. So we can add the following line todocs-website/graphql/generateGraphQLSchema.sh
: