Skip to content

Commit 12bc92f

Browse files
committed
0.0.66 react-apollo-network-status client.useApolloNetworkStatus
1 parent e44a4e0 commit 12bc92f

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

client.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { WebSocketLink } from 'apollo-link-ws';
55
import fetch from 'node-fetch';
66
import path from 'path';
77
import { debug } from './debug';
8+
import {createNetworkStatusNotifier} from 'react-apollo-network-status';
9+
import { NetworkStatus, UseApolloNetworkStatusOptions } from 'react-apollo-network-status/dist/src/useApolloNetworkStatus';
810

911
const moduleLog = debug.extend('client')
1012

@@ -41,6 +43,7 @@ export interface IApolloClient<T> extends ApolloClient<T> {
4143
jwt_token?: string;
4244
path?: string;
4345
ssl?: boolean;
46+
useApolloNetworkStatus?: (options?: UseApolloNetworkStatusOptions | undefined) => NetworkStatus;
4447
}
4548

4649
const host = typeof(window) === 'object' ? window.location.host : '';
@@ -100,11 +103,13 @@ export function generateApolloClient(
100103
// @ts-ignore
101104
httpLink,
102105
);
106+
107+
const {link: notifierLink, useApolloNetworkStatus} = createNetworkStatusNotifier();
103108

104109
const client: IApolloClient<any> = new ApolloClient({
105110
ssrMode: true,
106111
// @ts-ignore
107-
link: concat(authMiddleware, link),
112+
link: concat(notifierLink, concat(authMiddleware, link)),
108113
connectToDevTools: true,
109114
cache: new InMemoryCache({
110115
...forwardingArguments?.InMemoryCache,
@@ -130,6 +135,7 @@ export function generateApolloClient(
130135
client.jwt_token = options.token;
131136
client.path = options.path;
132137
client.ssl = options.ssl;
138+
client.useApolloNetworkStatus = useApolloNetworkStatus;
133139
log({ client });
134140

135141
return client;

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@deep-foundation/hasura",
3-
"version": "0.0.65",
3+
"version": "0.0.66",
44
"license": "Unlicense",
55
"author": "Ivan S Glazunov <[email protected]>",
66
"homepage": "https://github.com/deep-foundation/hasura",
@@ -22,6 +22,7 @@
2222
"node-fetch": "^2.6.1",
2323
"normalize-url": "^7.0.2",
2424
"path": "^0.12.7",
25+
"react-apollo-network-status": "^5.2.1",
2526
"rimraf": "^3.0.2",
2627
"ts-node": "^10.9.1",
2728
"ws": "^8.17.1"

0 commit comments

Comments
 (0)