-
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(graphql): add MutableTypeBatchResolver #4976
Merged
jjoyce0510
merged 23 commits into
datahub-project:master
from
noahfrn:graphql-mutable-batch-resolver
Aug 5, 2022
Merged
Changes from 2 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
8cae5ea
feat(graphql): add MutableType.batchUpdate method
noahfrn c40c672
feat(graphql): add MutableTypeBatchResolver.java
noahfrn 6cbdda8
feat(graphql): add MutableType.arrayInputClass method
noahfrn 6076b0c
fix(graphql): correct typos
noahfrn 87f17af
fix(graphql): throw exception when batchUpdate is called without bein…
noahfrn 88c046b
fix(graphql): fix typo
noahfrn ad65a42
feat(graphql): implement arrayInputClass for mutable types
noahfrn 4ac9b6f
test(graphql): add failure tests for MutableTypeBatchResolver
noahfrn 44d6afe
Merge branch 'datahub-project:master' into graphql-mutable-batch-reso…
noahfrn 759a9b0
feat(graphql): add batchUpdate support for Datasets
noahfrn 7ba0d97
fix(graphql): fix graphql checktyle violations
noahfrn 9f5845f
fix(graphql): fix typo
noahfrn ca09967
Merge branch 'datahub-project:master' into graphql-mutable-batch-reso…
noahfrn db7cc51
Add BatchDatasetUpdateInput and BatchMutableType
noahfrn 20de27d
fix(graphql): Add BatchMutableType
noahfrn 38f995a
fix(graphql): Revert whitespace change
noahfrn 98ce1d9
docs(graphql): Add field descriptions for BatchDatasetUpdateInput
noahfrn 04562fc
fix(graphql): Use more generic Urn class instead of CorpuserUrn
noahfrn 33a1957
test(graphql): Add MutableTypeBatchResolverTest success case
noahfrn ba8b8b1
style(graphql): Fix test checkstyle
noahfrn f638785
Merge branch 'master' into graphql-mutable-batch-resolver
noahfrn a11015b
Merge branch 'master' into graphql-mutable-batch-resolver
noahfrn be04661
Merge branch 'master' into graphql-mutable-batch-resolver
jjoyce0510 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
51 changes: 51 additions & 0 deletions
51
...src/main/java/com/linkedin/datahub/graphql/resolvers/mutate/MutableTypeBatchResolver.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,51 @@ | ||
package com.linkedin.datahub.graphql.resolvers.mutate; | ||
|
||
import com.codahale.metrics.Timer; | ||
import com.linkedin.datahub.graphql.exception.AuthorizationException; | ||
import com.linkedin.datahub.graphql.types.MutableType; | ||
import com.linkedin.metadata.utils.metrics.MetricUtils; | ||
import graphql.schema.DataFetcher; | ||
import graphql.schema.DataFetchingEnvironment; | ||
import java.util.concurrent.CompletableFuture; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import static com.linkedin.datahub.graphql.resolvers.ResolverUtils.*; | ||
|
||
|
||
/** | ||
* Generic GraphQL resolver responsible for performing updates against particular types. | ||
* | ||
* @param <I> the generated GraphQL POJO corresponding to the input type. | ||
* @param <T> the generated GraphQL POJO corresponding to the return type. | ||
*/ | ||
public class MutableTypeBatchResolver<I, T> implements DataFetcher<CompletableFuture<T>> { | ||
|
||
private static final Logger _logger = LoggerFactory.getLogger(MutableTypeResolverBatch.class.getName()); | ||
|
||
private final MutableType<I> _mutableType; | ||
|
||
public MutableTypeResolverBatch(final MutableType<I> mutableType) { | ||
_mutableType = mutableType; | ||
} | ||
|
||
@Override | ||
public CompletableFuture<T> get(DataFetchingEnvironment environment) throws Exception { | ||
final I[] inputs = bindArgument(environment.getArgument("inputs"), _mutableType.arrayInputClass()); | ||
|
||
return CompletableFuture.supplyAsync(() -> { | ||
Timer.Context timer = MetricUtils.timer(this.getClass(), "batchMutate").time(); | ||
|
||
try { | ||
return _mutableType.batchUpdate(inputs, environment.getContext()); | ||
} catch (AuthorizationException e) { | ||
throw e; | ||
} catch (Exception e) { | ||
_logger.error("Failed to perform batchUpdate", e); | ||
throw new IllegalArgumentException(e); | ||
} finally { | ||
timer.stop(); | ||
} | ||
}); | ||
} | ||
} |
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
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.
Thank you! Do you mind adding a unit test for this one?