Skip to content

Commit

Permalink
0.0.66 react-apollo-network-status client.useApolloNetworkStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
ivansglazunov committed Jul 11, 2024
1 parent e44a4e0 commit 12bc92f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
8 changes: 7 additions & 1 deletion client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { WebSocketLink } from 'apollo-link-ws';
import fetch from 'node-fetch';
import path from 'path';
import { debug } from './debug';
import {createNetworkStatusNotifier} from 'react-apollo-network-status';
import { NetworkStatus, UseApolloNetworkStatusOptions } from 'react-apollo-network-status/dist/src/useApolloNetworkStatus';

const moduleLog = debug.extend('client')

Expand Down Expand Up @@ -41,6 +43,7 @@ export interface IApolloClient<T> extends ApolloClient<T> {
jwt_token?: string;
path?: string;
ssl?: boolean;
useApolloNetworkStatus?: (options?: UseApolloNetworkStatusOptions | undefined) => NetworkStatus;
}

const host = typeof(window) === 'object' ? window.location.host : '';
Expand Down Expand Up @@ -100,11 +103,13 @@ export function generateApolloClient(
// @ts-ignore
httpLink,
);

const {link: notifierLink, useApolloNetworkStatus} = createNetworkStatusNotifier();

const client: IApolloClient<any> = new ApolloClient({
ssrMode: true,
// @ts-ignore
link: concat(authMiddleware, link),
link: concat(notifierLink, concat(authMiddleware, link)),
connectToDevTools: true,
cache: new InMemoryCache({
...forwardingArguments?.InMemoryCache,
Expand All @@ -130,6 +135,7 @@ export function generateApolloClient(
client.jwt_token = options.token;
client.path = options.path;
client.ssl = options.ssl;
client.useApolloNetworkStatus = useApolloNetworkStatus;
log({ client });

return client;
Expand Down
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@deep-foundation/hasura",
"version": "0.0.65",
"version": "0.0.66",
"license": "Unlicense",
"author": "Ivan S Glazunov <[email protected]>",
"homepage": "https://github.com/deep-foundation/hasura",
Expand All @@ -22,6 +22,7 @@
"node-fetch": "^2.6.1",
"normalize-url": "^7.0.2",
"path": "^0.12.7",
"react-apollo-network-status": "^5.2.1",
"rimraf": "^3.0.2",
"ts-node": "^10.9.1",
"ws": "^8.17.1"
Expand Down

0 comments on commit 12bc92f

Please sign in to comment.