Apollo-client: [v3] getMainDefinition is not exposed

Created on 31 Oct 2019  路  5Comments  路  Source: apollographql/apollo-client

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

Most helpful comment

import { getMainDefinition } from '@apollo/client/utilities';

All 5 comments

@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

Was this page helpful?
0 / 5 - 0 ratings