Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add subscription uri #338

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/core/apollo-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>;
Expand All @@ -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.
Expand All @@ -51,6 +53,7 @@ class ApolloClient extends OriginalApolloClient<Object> {
constructor(config: ApolloClientOptions) {
const {
uri,
subscriptionUri,
getAuthState,
getRefreshTokenParameters,
onAuthSuccess,
Expand Down Expand Up @@ -85,7 +88,7 @@ class ApolloClient extends OriginalApolloClient<Object> {
return definition.kind === 'OperationDefinition' && definition.operation === 'subscription';
},
new SubscriptionLink({
uri: 'wss://ws.8base.com',
uri: subscriptionUri || 'wss://ws.8base.com',
getAuthState,
onAuthError,
onIdTokenExpired,
Expand Down