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

Created on 16 Nov 2017  ·  5Comments  ·  Source: apollographql/apollo-link

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
);`
bug

Most helpful comment

All 5 comments

@jbaxleyiii tried with lazy but it doesn't work

Any update here? How are people doing this?

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

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.

Was this page helpful?
0 / 5 - 0 ratings