Apollo-client: TypeError: Cannot set property 'getFragmentDoc' of undefined

Created on 23 Jul 2020  ·  4Comments  ·  Source: apollographql/apollo-client

I'm trying out Apollo Client 3 with create-react-app. I'm getting the error below. Not sure what am I doing wrong.

Index.js

Screenshot 2020-07-23 at 4 28 37 PM

App.js

Screenshot 2020-07-23 at 4 28 11 PM

Actual outcome:
Screenshot 2020-07-23 at 4 27 30 PM

Versions

System:
    OS: macOS 10.15.6
Binaries:
    Node: 14.5.0 - /usr/local/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.5 - /usr/local/bin/npm
Browsers:
    Chrome: 81.0.4044.138
    Safari: 13.1.2
npmPackages:
    @apollo/client: ^3.0.2 => 3.0.2 

Most helpful comment

Can someone tell me what is the reason for this error?

The inmemorycache should be instantiated with "new" keyword.

All 4 comments

Can someone tell me what is the reason for this error?

This error occurs to me when I ordering parameters incorrectly in ApolloClient()

Can someone tell me what is the reason for this error?

The inmemorycache should be instantiated with "new" keyword.

Confirming @theneshofficial's answer (use new InMemoryCache()).

In strict mode, if you call a constructor function without new, this will be undefined. If you're using native class syntax rather than transpiling, constructor functions will throw an exception if you call them without using new, which helps prevent this problem, but most people are still transpiling class to function to support older browsers.

Was this page helpful?
0 / 5 - 0 ratings