Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

apollo-link-ws : Lazy or Connect after Login : Help #251

Closed
ignivalancy opened this issue Nov 16, 2017 · 5 comments
Closed

apollo-link-ws : Lazy or Connect after Login : Help #251

ignivalancy opened this issue Nov 16, 2017 · 5 comments
Labels

Comments

@ignivalancy
Copy link

ignivalancy commented Nov 16, 2017

I am using GraphQL subscriptions for realtime data from server. I want to connect with GraphQL subscriptions after login only. How to do this? In 1.0 we can do this lazy option but in 2.0 there is no option. Please Help.

`const hasSubscriptionOperation = ({ query: { definitions } }) =>
definitions.some(
({ kind, operation }) => kind === 'OperationDefinition' && operation === 'subscription',
)

// using ApolloLink.split to select link for each operation.
const apolloLink = ApolloLink.split(
    hasSubscriptionOperation,
    webSocketLink,
    httpLink
);`
@jbaxleyiii
Copy link
Contributor

@ignivalancy can you not set the lazy on the options for the ws transport? https://github.com/apollographql/subscriptions-transport-ws/blob/aefd199b18cd80553ec4f31687647022dfcbcfaa/src/client.ts#L67

@bogdansoare
Copy link

@jbaxleyiii tried with lazy but it doesn't work

@evans evans added the bug label Feb 15, 2018
@patricknazar
Copy link

Any update here? How are people doing this?

@odensc
Copy link

odensc commented Sep 5, 2018

lazy: true worked for me. Make sure you don't have a rogue component subscribing to something.

@JoviDeCroock
Copy link
Contributor

Since this issue is really outdated I am closing it but if you are still concerned about this feel free to reopen and I'll get back to you asap.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants