Skip to content

Commit

Permalink
[grid-ui] Adding error handler to Apollo, it is not decided yet how t…
Browse files Browse the repository at this point in the history
…o propagate information about handled errors to the components
  • Loading branch information
barancev committed Feb 18, 2021
1 parent 3db814d commit 78d66e8
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions javascript/grid-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
// specific language governing permissions and limitations
// under the License.

import {ApolloClient, ApolloProvider, InMemoryCache} from "@apollo/client";
import {ApolloClient, ApolloLink, ApolloProvider, HttpLink, InMemoryCache} from "@apollo/client";
import {onError} from "@apollo/client/link/error";
import {HashRouter as Router, Route, Switch} from "react-router-dom";
import React from "react";
import ReactModal from "react-modal";
Expand All @@ -28,16 +29,24 @@ import Typography from "@material-ui/core/Typography";
import Sessions from "./screens/Sessions/Sessions";
import Help from "./screens/Help/Help";

const errorLink = onError(({graphQLErrors, networkError}) => {
console.log('GQL ERROR', graphQLErrors, networkError)
});

const httpLink = new HttpLink({
uri: GridConfig.serverUri,
});

export const client = new ApolloClient({
link: ApolloLink.from([errorLink, httpLink]),
cache: new InMemoryCache(),
uri: GridConfig.serverUri,
});

function Copyright() {
// noinspection HtmlUnknownAnchorTarget
return (
<Typography variant="body2" color="textSecondary" align="center">
<Link href="#help">
<Link href="#/help">
Help
</Link>
{' - All rights reserved - '}
Expand All @@ -50,7 +59,6 @@ function Copyright() {
);
}


const useStyles = makeStyles((theme) => ({
root: {
display: "flex",
Expand Down

0 comments on commit 78d66e8

Please sign in to comment.