[createClient.ts] refactor
This commit is contained in:
parent
03542b8564
commit
446c0cff29
|
@ -3,11 +3,11 @@ import {
|
|||
InMemoryCache,
|
||||
NormalizedCacheObject,
|
||||
ApolloLink,
|
||||
} from "@apollo/client";
|
||||
import { createUploadLink } from "apollo-upload-client";
|
||||
import { onError } from "@apollo/client/link/error";
|
||||
import createAuthMiddleware from "./links/authMiddleware";
|
||||
import TokenStorage from "libs/tokenstorage/TokenStorage";
|
||||
} from '@apollo/client';
|
||||
import { createUploadLink } from 'apollo-upload-client';
|
||||
import { onError } from '@apollo/client/link/error';
|
||||
import createAuthMiddleware from './links/authMiddleware';
|
||||
import TokenStorage from 'libs/tokenstorage/TokenStorage';
|
||||
|
||||
const createClient = (
|
||||
uri: string,
|
||||
|
@ -19,14 +19,17 @@ const createClient = (
|
|||
link: ApolloLink.from([
|
||||
createAuthMiddleware(tokenStorage),
|
||||
onError(({ graphQLErrors, networkError }) => {
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
if (graphQLErrors)
|
||||
graphQLErrors.map(({ message, locations, path }) =>
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
if (graphQLErrors) {
|
||||
graphQLErrors.forEach(({ message, locations, path }) =>
|
||||
console.log(
|
||||
`[GraphQL error]: Message: ${message}, Location: ${locations}, Path: ${path}`
|
||||
)
|
||||
);
|
||||
if (networkError) console.log(`[Network error]: ${networkError}`);
|
||||
}
|
||||
if (networkError) {
|
||||
console.log(`[Network error]: ${networkError}`);
|
||||
}
|
||||
}
|
||||
}),
|
||||
createUploadLink({
|
||||
|
|
Reference in New Issue