[2.6.0] TypeError: Cannot read property 'some' of undefined
See original GitHub issueDescription
Just tried to update apollo-server-express
from 2.5.1 → 2.6.0 but it’s failing with the following:
TypeError: Cannot read property 'some' of undefined
61 |
> 62 | const apolloServer = new ApolloServer({
| ^
at typeDefs.some.typeDef (node_modules/apollo-server-core/src/utils/isDirectiveDefined.ts:8:25)
at Array.some (<anonymous>)
at Object.<anonymous>.exports.isDirectiveDefined (node_modules/apollo-server-core/src/utils/isDirectiveDefined.ts:7:12)
at new ApolloServerBase (node_modules/apollo-server-core/src/ApolloServer.ts:275:12)
at new ApolloServer (node_modules/apollo-server-express/src/ApolloServer.ts:84:5)
It appears this only happens when importing typeDefs from an SDL file.
Reproduction
Glitch Remix (see server.js line 5, and open the logs)
Hacky Workaround
I modified isDirectiveDefined
locally to include a truthiness check and that works, but I’m not sure if that’s a real fix or just masking an actual problem (e.g. should all typeDef
objects have a definitions
property, or is undefined
valid?).
packages/apollo-server-core/src/utils/isDirectiveDefined.ts#L8
typeDefs.some(typeDef =>
- typeDef.definitions.some(
+ typeDef.definitions && typeDef.definitions.some(
definition =>
The code indicates typeDef
is of type DocumentNode
from graphql/language
but I didn’t see DocumentNode
in the exported type definitions and ran out of time to chase that further. ¯\_(ツ)_/¯
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Cannot Read Property of Undefined in JavaScript - Rollbar
What Causes TypeError: Cannot Read Property of Undefined. Undefined means that a variable has been declared but has not been assigned a value....
Read more >TypeError: Cannot read property 'some' of undefined
javascript - I keep getting this error "TypeError: Cannot read property 'some' of undefined" - Stack Overflow. Stack Overflow for Teams – Start ......
Read more >typeerror can not read property x of null - YouTube
Join this channel to get access to perks:https://www.youtube.com/channel/UCoSpmr2KNOxjwE_B9ynUmig/joinMy GearCamera ...
Read more >error: cannot read properties of undefined (reading 'refresh')
Your issue is that your .find() method is returning undefined , so you can't access properties on product such as .name as it...
Read more >Cannot read properties of undefined (reading 'component')
Uncaught TypeError: Cannot read properties of undefined (reading 'component'). I have gone word blind, I can not see the error. For some reason...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Bump this issue for latest 2.6.6
Passing
string
totypeDefs
triggers same error unless wrap it ingql
.Fixed in 2.6.1 (#2754), thanks to the both of you! 🚀