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 read properties of undefined (reading 'FIELD')

See original GitHub issue

Intended outcome: Get apollo-client working on codesandbox.io react template

Actual outcome: Receiving the following error when I attempt to initialize an ApolloClient instance in step 2 following this guide https://www.apollographql.com/docs/react/get-started/

Here is the code sandbox: https://codesandbox.io/s/naughty-wiles-ygmexk?file=/src/App.js

Here is the error:

`TypeError: Cannot read properties of undefined (reading ‘FIELD’) at $csb$eval (https://qt7y3u.csb.app/node_modules/graphql/type/directives.mjs:66:50)

at H (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:99995)

at K.evaluate (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112747)

at ge.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:123129)

at c (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112362)

at $csb$eval (https://qt7y3u.csb.app/node_modules/graphql/type/validate.mjs:13:29)

at H (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:99995)

at K.evaluate (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112747)

at ge.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:123129)

at c (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112362)

at $csb$eval (https://qt7y3u.csb.app/node_modules/graphql/graphql.mjs:11:32)

at H (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:99995)

at K.evaluate (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112747)

at ge.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:123129)

at c (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112362)

at $csb$eval (https://qt7y3u.csb.app/node_modules/graphql/index.mjs:25:26)

at H (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:99995)

at K.evaluate (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112747)

at ge.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:123129)

at c (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112362)

at $csb$eval (https://qt7y3u.csb.app/node_modules/@apollo/client/utilities/globals/fix-graphql.js:8:21)

at H (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:99995)

at K.evaluate (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112747)

at ge.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:123129)

at c (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112362)

at $csb$eval (https://qt7y3u.csb.app/node_modules/@apollo/client/utilities/globals/index.js:30:29)

at H (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:99995)

at K.evaluate (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112747)

at ge.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:123129)

at c (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112362)

at $csb$eval (https://qt7y3u.csb.app/node_modules/@apollo/client/core/index.js:13:23)

at H (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:99995)

at K.evaluate (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112747)

at ge.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:123129)

at c (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112362)

at $csb$eval (https://qt7y3u.csb.app/node_modules/@apollo/client/index.js:5:28)

at H (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:99995)

at K.evaluate (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112747)

at ge.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:123129)

at c (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112362)

at $csb$eval (https://qt7y3u.csb.app/src/index.js:9:16)

at H (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:99995)

at K.evaluate (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:112747)

at ge.evaluateTranspiledModule (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:123129)

at ge.evaluateModule (https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:122628)

at https://codesandbox.io/static/js/sandbox.0af6ff135.js:1:318342

at c (https://codesandbox.io/static/js/vendors~app~embed~sandbox~sandbox-startup.bcc15d438.chunk.js:1:3629)

at Generator._invoke (https://codesandbox.io/static/js/vendors~app~embed~sandbox~sandbox-startup.bcc15d438.chunk.js:1:3382)

at Generator.forEach.t.<computed> [as next] (https://codesandbox.io/static/js/vendors~app~embed~sandbox~sandbox-startup.bcc15d438.chunk.js:1:3986)

at r (https://codesandbox.io/static/js/vendors~app~embed~sandbox~sandbox-startup.bcc15d438.chunk.js:1:206)`

How to reproduce the issue: go to codesandbox.io and create a new sandbox with their official react template and then follow the steps in this guide https://www.apollographql.com/docs/react/get-started/

Versions cant find terminal to run supplied command, instead here is a screenshot image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jpvajdacommented, Jun 1, 2022

@StephenBarlow It sounds like we have dependency version issue on this particular code sandbox tutorial Could we update the sandbox package.json to more current versions of each package type?

1reaction
sleekyomcommented, May 26, 2022

I ran into the same issue and I was able to fix it by changing the react version used in the sandbox.

@apollo/client”: “3.6.2”, “graphql”: “15.8.0”, “react”: “17.0.2” This dependencies version fix the issue for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read properties of undefined (reading 'id')
I have this error in my terminal: TypeError: Cannot read properties of undefined (reading 'id').
Read more >
Resolving TypeError: Cannot Read Property of Undefined ...
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
[Solved] Cannot read Properties of Undefined in JavaScript
The "Cannot read properties of undefined" error occurs when you try to access a property or a method on a variable that stores...
Read more >
Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError: Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an undefined...
Read more >
Cannot read property 'fields' of undefined
The error is actually triggered from get accountName. I used so many console logs to understand the order of execution and understand that ......
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