apollo-state-sync - API Reference (Users)
    Preparing search index...

    Variable stateSyncLinkConst

    stateSyncLink: ApolloLink = ...

    A non-terminating ApolloLink, which tracks the count of in-flight GraphQL requests.

    This link is required when using the apollo-state-sync library.

    diagram that explains the logic with an example.

    import { GraphQLWsLink } from '@apollo/client'
    import { stateSyncLink } from 'apollo-state-sync'
    import { createSharedClient } from 'graphql-shared-ws'

    const wsLink = new GraphQLWsLink(
    createSharedClient({
    url: 'wss://localhost:443/api/graphql',
    })
    )

    const apolloClient = new ApolloClient({
    link: ApolloLink.from([
    authMiddleware,

    // use stateSyncLink
    stateSyncLink,

    wsLink,
    ]),
    cache: inMemoryStore,
    })