-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rwa): check a check banner if the graphql backend is online (#2773)
- Loading branch information
1 parent
839d61f
commit 2c9828f
Showing
6 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
--- |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/apps/rwa-demo/src/components/GraphOnlineBanner/GraphOnlineBanner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useNetworkInfoQuery } from '@/__generated__/sdk'; | ||
import { NETWORK_POLLING_RATE } from '@/constants'; | ||
import { Notification } from '@kadena/kode-ui'; | ||
import type { FC } from 'react'; | ||
import { useEffect } from 'react'; | ||
|
||
export const GraphOnlineBanner: FC = () => { | ||
const variables = { | ||
pollInterval: NETWORK_POLLING_RATE, | ||
}; | ||
|
||
const { error, stopPolling } = useNetworkInfoQuery(variables); | ||
|
||
useEffect(() => { | ||
return () => { | ||
stopPolling(); | ||
}; | ||
}, []); | ||
|
||
if (!error) return; | ||
return ( | ||
<Notification role="status" intent="warning"> | ||
The Graphql backend is down | ||
</Notification> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/apps/rwa-demo/src/services/graph/network-info.graph.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { gql } from '@apollo/client'; | ||
import type { DocumentNode } from 'graphql'; | ||
|
||
export const networkInfo: DocumentNode = gql` | ||
query networkInfo { | ||
networkInfo { | ||
apiVersion | ||
} | ||
} | ||
`; |