-
Notifications
You must be signed in to change notification settings - Fork 3k
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(versionedDataset): adds a versionStamp to timeline response & adds versionStamp param to dataset graphql #4727
Changes from all commits
1af4136
3110642
c5cd6c6
80318e1
8148210
3415866
cacce49
d1b186b
29eefaf
563e4f9
c79f862
9c91147
23cb905
2403710
edc2487
36b08db
4f923ba
a7f29f1
ddda27a
8427360
7f16a76
03ad8c2
988ddc8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,24 +18,25 @@ | |
* for the provided {@link LoadableType} under the name provided by {@link LoadableType#name()} | ||
* | ||
* @param <T> the generated GraphQL POJO corresponding to the resolved type. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
* @param <K> the key type for the DataLoader | ||
*/ | ||
public class LoadableTypeResolver<T> implements DataFetcher<CompletableFuture<T>> { | ||
public class LoadableTypeResolver<T, K> implements DataFetcher<CompletableFuture<T>> { | ||
|
||
private final LoadableType<T> _loadableType; | ||
private final Function<DataFetchingEnvironment, String> _urnProvider; | ||
private final LoadableType<T, K> _loadableType; | ||
private final Function<DataFetchingEnvironment, K> _keyProvider; | ||
|
||
public LoadableTypeResolver(final LoadableType<T> loadableType, final Function<DataFetchingEnvironment, String> urnProvider) { | ||
public LoadableTypeResolver(final LoadableType<T, K> loadableType, final Function<DataFetchingEnvironment, K> keyProvider) { | ||
_loadableType = loadableType; | ||
_urnProvider = urnProvider; | ||
_keyProvider = keyProvider; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<T> get(DataFetchingEnvironment environment) { | ||
final String urn = _urnProvider.apply(environment); | ||
if (urn == null) { | ||
final K key = _keyProvider.apply(environment); | ||
if (key == null) { | ||
return null; | ||
} | ||
final DataLoader<String, T> loader = environment.getDataLoaderRegistry().getDataLoader(_loadableType.name()); | ||
return loader.load(urn); | ||
final DataLoader<K, T> loader = environment.getDataLoaderRegistry().getDataLoader(_loadableType.name()); | ||
return loader.load(key); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,9 @@ | |
* Extension of {@link EntityType} containing methods required for 'browse' functionality. | ||
* | ||
* @param <T>: The GraphQL object type corresponding to the entity, must extend the `Entity` interface. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update |
||
* @param <K> the key type for the DataLoader | ||
*/ | ||
public interface BrowsableEntityType<T extends Entity> extends EntityType<T> { | ||
public interface BrowsableEntityType<T extends Entity, K> extends EntityType<T, K> { | ||
|
||
/** | ||
* Retrieves {@link BrowseResults} corresponding to a given path, list of filters, start, & count. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
package com.linkedin.datahub.graphql.types; | ||
|
||
import com.linkedin.datahub.graphql.generated.Entity; | ||
import java.util.function.Function; | ||
|
||
|
||
/** | ||
* GQL graph type representing a top-level GMS entity (eg. Dataset, User, DataPlatform, Chart, etc.). | ||
* | ||
* @param <T>: The GraphQL object type corresponding to the entity, must be of type {@link Entity} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update |
||
* @param <K> the key type for the DataLoader | ||
*/ | ||
public interface EntityType<T extends Entity> extends LoadableType<T> { | ||
public interface EntityType<T extends Entity, K> extends LoadableType<T, K> { | ||
|
||
/** | ||
* Retrieves the {@link com.linkedin.datahub.graphql.generated.EntityType} associated with the Graph type, eg. 'DATASET' | ||
*/ | ||
com.linkedin.datahub.graphql.generated.EntityType type(); | ||
|
||
Function<Entity, K> getKeyProvider(); | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,9 @@ | |
* GQL graph type that can be loaded from a downstream service by primary key. | ||
* | ||
* @param <T>: The GraphQL object type corresponding to the type. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update |
||
* @param <K> the key type for the DataLoader | ||
*/ | ||
public interface LoadableType<T> { | ||
public interface LoadableType<T, K> { | ||
|
||
/** | ||
* Returns generated GraphQL class associated with the type | ||
|
@@ -29,20 +30,20 @@ default String name() { | |
/** | ||
* Retrieves an entity by urn string. Null is provided in place of an entity object if an entity cannot be found. | ||
* | ||
* @param urn to retrieve | ||
* @param key to retrieve | ||
* @param context the {@link QueryContext} corresponding to the request. | ||
*/ | ||
default DataFetcherResult<T> load(@Nonnull final String urn, @Nonnull final QueryContext context) throws Exception { | ||
return batchLoad(ImmutableList.of(urn), context).get(0); | ||
default DataFetcherResult<T> load(@Nonnull final K key, @Nonnull final QueryContext context) throws Exception { | ||
return batchLoad(ImmutableList.of(key), context).get(0); | ||
}; | ||
|
||
/** | ||
* Retrieves an list of entities given a list of urn strings. The list returned is expected to | ||
* be of same length of the list of urns, where nulls are provided in place of an entity object if an entity cannot be found. | ||
* | ||
* @param urns to retrieve | ||
* @param keys to retrieve | ||
* @param context the {@link QueryContext} corresponding to the request. | ||
*/ | ||
List<DataFetcherResult<T>> batchLoad(@Nonnull final List<String> urns, @Nonnull final QueryContext context) throws Exception; | ||
List<DataFetcherResult<T>> batchLoad(@Nonnull final List<K> keys, @Nonnull final QueryContext context) throws Exception; | ||
|
||
} |
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.
Update with new generic