Skip to content
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

fix(ui): Adding view, forms GraphQL query, remove showing a fallback error message on unhandled GraphQL error #11084

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1032,6 +1032,8 @@ private void configureQueryResolvers(final RuntimeWiring.Builder builder) {
.dataFetcher("mlModel", getResolver(mlModelType))
.dataFetcher("mlModelGroup", getResolver(mlModelGroupType))
.dataFetcher("assertion", getResolver(assertionType))
.dataFetcher("form", getResolver(formType))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add error handling for the new data fetcher.

The new data fetcher for form should include error handling to ensure robustness.

+ .dataFetcher("form", env -> {
+   try {
+     return getResolver(formType).get(env);
+   } catch (Exception e) {
+     log.error("Failed to fetch form data", e);
+     throw new RuntimeException("Error fetching form data", e);
+   }
+ })
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.dataFetcher("form", getResolver(formType))
.dataFetcher("form", env -> {
try {
return getResolver(formType).get(env);
} catch (Exception e) {
log.error("Failed to fetch form data", e);
throw new RuntimeException("Error fetching form data", e);
}
})

.dataFetcher("view", getResolver(dataHubViewType))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add error handling for the new data fetcher.

The new data fetcher for view should include error handling to ensure robustness.

+ .dataFetcher("view", env -> {
+   try {
+     return getResolver(dataHubViewType).get(env);
+   } catch (Exception e) {
+     log.error("Failed to fetch view data", e);
+     throw new RuntimeException("Error fetching view data", e);
+   }
+ })
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.dataFetcher("view", getResolver(dataHubViewType))
.dataFetcher("view", env -> {
try {
return getResolver(dataHubViewType).get(env);
} catch (Exception e) {
log.error("Failed to fetch view data", e);
throw new RuntimeException("Error fetching view data", e);
}
})

.dataFetcher("listPolicies", new ListPoliciesResolver(this.entityClient))
.dataFetcher("getGrantedPrivileges", new GetGrantedPrivilegesResolver())
.dataFetcher("listUsers", new ListUsersResolver(this.entityClient))
Expand Down
6 changes: 6 additions & 0 deletions datahub-graphql-core/src/main/resources/entity.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ type Query {
Fetch a Tag by primary key (urn)
"""
tag(urn: String!): Tag

"""
Fetch a View by primary key (urn)
"""
view(urn: String!): DataHubView

jjoyce0510 marked this conversation as resolved.
Show resolved Hide resolved
"""
Fetch a Role by primary key (urn)
"""
Expand Down
15 changes: 8 additions & 7 deletions datahub-web-react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ const errorLink = onError((error) => {
window.location.replace(`${PageRoutes.AUTHENTICATE}?redirect_uri=${encodeURIComponent(currentPath)}`);
}
}
if (graphQLErrors && graphQLErrors.length) {
const firstError = graphQLErrors[0];
const { extensions } = firstError;
const errorCode = extensions && (extensions.code as number);
// Fallback in case the calling component does not handle.
message.error(`${firstError.message} (code ${errorCode})`, 3);
}
// Disabled behavior for now -> Components are expected to handle their errors.
// if (graphQLErrors && graphQLErrors.length) {
// const firstError = graphQLErrors[0];
// const { extensions } = firstError;
// const errorCode = extensions && (extensions.code as number);
// // Fallback in case the calling component does not handle.
// message.error(`${firstError.message} (code ${errorCode})`, 3); // TODO: Decide if we want this back.
// }
Comment on lines +33 to +40
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder: Reconsider the necessity of centralized error handling.

The TODO comment indicates that the necessity of this error handling should be reconsidered in the future.

Do you want me to open a GitHub issue to track this task?

});

const client = new ApolloClient({
Expand Down
6 changes: 6 additions & 0 deletions datahub-web-react/src/graphql/view.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ query listGlobalViews($start: Int!, $count: Int!, $query: String) {
}
}

query getView($urn: String!) {
view(urn: $urn) {
...view
}
}

mutation createView($input: CreateViewInput!) {
createView(input: $input) {
...view
Expand Down
Loading