question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot set property 'getFragmentDoc' of undefined

See original GitHub issue

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 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

38reactions
theneshofficialcommented, Aug 3, 2020

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

The inmemorycache should be instantiated with “new” keyword.

8reactions
benjamncommented, Aug 3, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot set property 'firstname' of undefined at new ...
You defined a type, but its value is still undefined import { Component, OnInit } from '@angular/core'; export class User { constructor( ...
Read more >
class InMemoryCache - Apollo GraphQL Docs
Writes data to the cache in the shape of a provided GraphQL query. Returns a Reference to the written object or undefined if...
Read more >
Uncaught TypeError: Cannot set property
In JavaScript if a variable has been declared, but has not been assigned a value, is automatically assigned the value undefined.
Read more >
How to solve the 'cannot set property of undefined' issue on ...
Therefore, if you try to access the value of such variable, it will throw Uncaught TypeError cannot set property '0' of undefined/null ....
Read more >
Renovate Bot Package Diff
InvariantError("Cannot automatically merge arrays") : new tsInvariant. ... }\n catch (e) {\n if (e instanceof TypeError)\n return null;\n throw e;\n }\n }\n ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found