getMainDefinition utility function is not exposed from @apollo/client.
As a result, the examples on your doc are inaccurate :/
https://www.apollographql.com/docs/react/data/subscriptions/#client-setup
Intended outcome:
import { getMainDefinition } from '@apollo/client'; should work
Actual outcome:
But import { getMainDefinition } from '@apollo/client'; throw this error Module ... has no exported member 'getMainDefinition'.
Version
3.0.0-beta.1
@hwillson This looks like something that could be enabled by exposing the @apollo/client/utilities entry point we talked about, right?
This is also present in 2.6.8
This was fixed a few beta releases ago; import { getMainDefinition } from '@apollo/client;` should now work properly. Thanks!
import { getMainDefinition } from '@apollo/client/utilities';
import { getMainDefinition } from '@apollo/client/utilities';
Had to use this as
import { getMainDefinition } from '@apollo/client; is not exposed
Most helpful comment