-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Graph queries: Add and update names * Add graphql-exchanges Update graphql query names Reorder imports * Rename subscription and query names * Do minor refactor and add comments
- Loading branch information
1 parent
160a3eb
commit 3008cef
Showing
11 changed files
with
95 additions
and
92 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
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
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,37 @@ | ||
import { fetchExchange, subscriptionExchange } from 'urql' | ||
import { SubscriptionClient } from 'subscriptions-transport-ws' | ||
import { captureMessage } from '@sentry/browser' | ||
import endpoints from './endpoints' | ||
|
||
const GRAPH_API_ENDPOINTS = endpoints() | ||
const subscriptionClient = new SubscriptionClient(GRAPH_API_ENDPOINTS[1], { | ||
reconnect: true, | ||
reconnectionAttempts: 10, | ||
}) | ||
|
||
// Default exchanges | ||
const DEFAULT_FETCH_EXCHANGE = fetchExchange | ||
const DEFAULT_SUBSCRIPTION_EXCHANGE = subscriptionExchange({ | ||
forwardSubscription: operation => subscriptionClient.request(operation), | ||
}) | ||
|
||
export function getFetchExchange() { | ||
return DEFAULT_FETCH_EXCHANGE | ||
} | ||
|
||
export function getSubscriptionExchange() { | ||
return DEFAULT_SUBSCRIPTION_EXCHANGE | ||
} | ||
|
||
let connectionAttempts = 0 | ||
subscriptionClient.onConnected(() => (connectionAttempts = 0)) | ||
|
||
// Check for connection errors and if reaches max attempts send error log to Sentry | ||
subscriptionClient.onError(err => { | ||
const maxReconnectionAttempts = subscriptionClient.reconnectionAttempts | ||
|
||
if (maxReconnectionAttempts === ++connectionAttempts) { | ||
captureMessage(`Connection error, could not connect to ${err.target.url}`) | ||
} | ||
console.log('Retrying connection...') | ||
}) |
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
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
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
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
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
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
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
Oops, something went wrong.
3008cef
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to following URLs: