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
);`
@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
@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.
Most helpful comment
@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