gatsby-transformer-json crashes when .json file in directory starting with a number
See original GitHub issueDescription
When running gatsby develop if you have the gatsby-transformer-json installed and anywhere in you file system you have a .json file directly inside a directory that starts with a number gatsby will crash with
UNHANDLED REJECTION Syntax Error: Unexpected Int "20"
GraphQLError: Syntax Error: Unexpected Int "20"
- TypeMapper.js:113 TypeMapper.createType
[gatsby-json-crasher]/[graphql-compose]/lib/TypeMapper.js:113:43
- ObjectTypeComposer.js:80 Function.createTemp
[gatsby-json-crasher]/[graphql-compose]/lib/ObjectTypeComposer.js:80:28
- ObjectTypeComposer.js:56 Function.create
[gatsby-json-crasher]/[graphql-compose]/lib/ObjectTypeComposer.js:56:21
- index.js:59
Steps to reproduce
add
“gatsby-transformer-json”
{
resolve: gatsby-source-filesystem
,
options: {
path: ${__dirname}/src/assets
,
},
},
to your gatsby-config.js
create a directory called 20m in your src/assets directory create a file called test.json in your src/assets/20m directory with the contents
{
"test":"crash time"
}
Expected result
Json Data should be added to the system
Actual result
gatsby develop crashes:
UNHANDLED REJECTION Syntax Error: Unexpected Int "20"
GraphQLError: Syntax Error: Unexpected Int "20"
- TypeMapper.js:113 TypeMapper.createType
[gatsby-json-crasher]/[graphql-compose]/lib/TypeMapper.js:113:43
Environment
System:
OS: Windows 10 10.0.17763
CPU: (16) x64 AMD Ryzen 7 1800X Eight-Core Processor
Binaries:
Node: 12.14.0 - C:\Program Files\nodejs\node.EXE
npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 44.17763.831.0
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:11 (7 by maintainers)
Top GitHub Comments
@vladar Agreed that does allow someone to deal with invalid folder names. To verify I dropped this function in which allowed everything to build fine.
That being said it’d still be great to give a better error message than
UNHANDLED REJECTION Syntax Error: Unexpected Int “20”
I don’t think that error message is going to lead most people to quickly figure out what’s wrong. It probably also wouldn’t hurt to drop some info on the gatsby-transformer-json plugin doc about this situation. But that probably belongs in another issue?
Closing this as stale since in the meantime Gatsby v3 and updated related packages were released. Please try with the latest versions and if you still see this problem open a new bug report (it must include a minimal reproduction).