From b0e7d1954c471e999d17ca853a4e1d14e44532ad Mon Sep 17 00:00:00 2001 From: Vyacheslav 'SLEL' Solomin Date: Thu, 25 Feb 2021 21:24:14 +0300 Subject: [PATCH] feat: add subscription uri --- packages/core/apollo-client/src/index.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/core/apollo-client/src/index.ts b/packages/core/apollo-client/src/index.ts index 40fadae8..81949591 100644 --- a/packages/core/apollo-client/src/index.ts +++ b/packages/core/apollo-client/src/index.ts @@ -14,6 +14,7 @@ import gql from 'graphql-tag'; type ApolloClientCommon = { uri: string; + subscriptionUri?: string; extendLinks?: (links: ApolloLink[], options: { getAuthState?: () => IAuthState }) => ApolloLink[]; onAuthError?: (error?: {}) => void; onIdTokenExpired?: () => Promise; @@ -36,6 +37,7 @@ type ApolloClientOptions = { * * @param {Object} config - The Apollo Client config. * @param {string} config.uri Endpoint of the GraphQl server. + * @param {string} config.subscriptionUri Endpoint of the GraphQl websocket server. * @param {Function} config.getAuthState - The function which are using to get auth state. * @param {Function} config.getRefreshTokenParameters - The function which are using for get refresh token parameters. * @param {Function} config.onAuthSuccess - The callback which called when attempt to refresh authentication is success. @@ -51,6 +53,7 @@ class ApolloClient extends OriginalApolloClient { constructor(config: ApolloClientOptions) { const { uri, + subscriptionUri, getAuthState, getRefreshTokenParameters, onAuthSuccess, @@ -85,7 +88,7 @@ class ApolloClient extends OriginalApolloClient { return definition.kind === 'OperationDefinition' && definition.operation === 'subscription'; }, new SubscriptionLink({ - uri: 'wss://ws.8base.com', + uri: subscriptionUri || 'wss://ws.8base.com', getAuthState, onAuthError, onIdTokenExpired,