mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-28 02:17:53 +00:00
fix(ui): Adding view, forms GraphQL query, remove showing a fallback error message on unhandled GraphQL error (#11084)
Co-authored-by: John Joyce <john@ip-192-168-1-200.us-west-2.compute.internal>
This commit is contained in:
parent
9e413aaee3
commit
8657288f29
@ -1032,6 +1032,8 @@ public class GmsGraphQLEngine {
|
||||
.dataFetcher("mlModel", getResolver(mlModelType))
|
||||
.dataFetcher("mlModelGroup", getResolver(mlModelGroupType))
|
||||
.dataFetcher("assertion", getResolver(assertionType))
|
||||
.dataFetcher("form", getResolver(formType))
|
||||
.dataFetcher("view", getResolver(dataHubViewType))
|
||||
.dataFetcher("listPolicies", new ListPoliciesResolver(this.entityClient))
|
||||
.dataFetcher("getGrantedPrivileges", new GetGrantedPrivilegesResolver())
|
||||
.dataFetcher("listUsers", new ListUsersResolver(this.entityClient))
|
||||
|
||||
@ -68,6 +68,17 @@ type Query {
|
||||
Fetch a Tag by primary key (urn)
|
||||
"""
|
||||
tag(urn: String!): Tag
|
||||
|
||||
"""
|
||||
Fetch a View by primary key (urn)
|
||||
"""
|
||||
view(urn: String!): DataHubView
|
||||
|
||||
"""
|
||||
Fetch a Form by primary key (urn)
|
||||
"""
|
||||
form(urn: String!): Form
|
||||
|
||||
"""
|
||||
Fetch a Role by primary key (urn)
|
||||
"""
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import React from 'react';
|
||||
import Cookies from 'js-cookie';
|
||||
import { message } from 'antd';
|
||||
import { BrowserRouter as Router } from 'react-router-dom';
|
||||
import { ApolloClient, ApolloProvider, createHttpLink, InMemoryCache, ServerError } from '@apollo/client';
|
||||
import { onError } from '@apollo/client/link/error';
|
||||
@ -21,7 +20,7 @@ import { useCustomTheme } from './customThemeContext';
|
||||
const httpLink = createHttpLink({ uri: '/api/v2/graphql' });
|
||||
|
||||
const errorLink = onError((error) => {
|
||||
const { networkError, graphQLErrors } = error;
|
||||
const { networkError } = error;
|
||||
if (networkError) {
|
||||
const serverError = networkError as ServerError;
|
||||
if (serverError.statusCode === ErrorCodes.Unauthorized) {
|
||||
@ -31,13 +30,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.
|
||||
// }
|
||||
});
|
||||
|
||||
const client = new ApolloClient({
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user