Then when I generated a cell I got a similar error…
ajoslin$ yarn rw g cell helmet
yarn run v1.22.10
$ /Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/.bin/rw g cell helmet
✔ Generating cell files...
✔ Successfully wrote file `./web/src/components/HelmetCell/HelmetCell.mock.ts`
✔ Successfully wrote file `./web/src/components/HelmetCell/HelmetCell.test.tsx`
✔ Successfully wrote file `./web/src/components/HelmetCell/HelmetCell.stories.tsx`
✔ Successfully wrote file `./web/src/components/HelmetCell/HelmetCell.tsx`
✖ Generating types ...
→ Unexpected token, expected "}" (68:9)
Unexpected token, expected "}" (68:9)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The error on startup
gen | (node:91303) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token, expected "}" (68:9)
gen | at Object._raise (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:810:17)
gen | at Object.raiseWithData (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:803:17)
gen | at Object.raise (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:764:17)
gen | at Object.unexpected (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:9980:16)
gen | at Object.expect (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:9954:28)
gen | at Object.jsxParseExpressionContainer (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:5154:10)
gen | at Object.jsxParseElementAt (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:5245:36)
gen | at Object.jsxParseElement (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:5288:17)
gen | at Object.parseExprAtom (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:5295:19)
gen | at Object.parseExprSubscripts (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:10954:23)
gen | (Use `node --trace-warnings ...` to show where the warning was created)
gen | (node:91303) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
gen | (node:91303) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I don’t know how to turn on node --trace-warnings in Redwood
Do you already have in your SDL a query defined for fetching a “helmet” by id?
For example:
type Helmet {
id: Int!
title: String!
meta: String!
description: String!
}
type Query {
helmet(id: Int!): Helmet
}
If you don’t have the above SDL defined when generating a cell via
yarn rw g cell helmet
and because you are using Typescript, it will cause some type errors like:
✔ Generating cell files...
✔ Successfully wrote file `./web/src/components/HelmetCell/HelmetCell.mock.ts`
✔ Successfully wrote file `./web/src/components/HelmetCell/HelmetCell.test.tsx`
✔ Successfully wrote file `./web/src/components/HelmetCell/HelmetCell.stories.tsx`
✔ Successfully wrote file `./web/src/components/HelmetCell/HelmetCell.tsx`
⠹ Generating types ...
GraphQLDocumentError: Unknown type "Int".
at /x/web/src/components/HelmetCell/HelmetCell.tsx:
1:28
GraphQLDocumentError: Cannot query field "helmet" on type "Query".
at /x/web/src/components/HelmetCell/HelmetCell.tsx:
2:3
GraphQLDocumentError: Unknown type "Int".
at /x/web/src/components/HelmetCell/HelmetCell.tsx:
1:28
But if a SDL is defined properly with the expected Int, it would be ok.
Or, maybe your SDL is malformed?
You can try to correct and then regenerate types via
The problem is repeatable w/yarn rw g types – I’ev been through and thru the .sdl and it all looks fine !!
What other files get processed when I run rw g types ?
I ran yarn rw lint and while there was a ton of output I saw nothing that would have been this error
I managed to set --trace-warnings like this: NODE_OPTIONS=--trace-warnings yarn rw g types
The error was no more helpful (but it was more)
Generating...
(node:28659) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token, expected "}" (81:9)
at Object._raise (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:810:17)
at Object.raiseWithData (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:803:17)
at Object.raise (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:764:17)
at Object.unexpected (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:9980:16)
at Object.expect (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:9954:28)
at Object.jsxParseExpressionContainer (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:5154:10)
at Object.jsxParseElementAt (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:5245:36)
at Object.jsxParseElement (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:5288:17)
at Object.parseExprAtom (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:5295:19)
at Object.parseExprSubscripts (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:10954:23)
at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
at processPromiseRejections (internal/process/promises.js:247:11)
at processTicksAndRejections (internal/process/task_queues.js:94:32)
(node:28659) SyntaxError: Unexpected token, expected "}" (81:9)
at Object._raise (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:810:17)
at Object.raiseWithData (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:803:17)
at Object.raise (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:764:17)
at Object.unexpected (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:9980:16)
at Object.expect (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:9954:28)
at Object.jsxParseExpressionContainer (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:5154:10)
at Object.jsxParseElementAt (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:5245:36)
at Object.jsxParseElement (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:5288:17)
at Object.parseExprAtom (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:5295:19)
at Object.parseExprSubscripts (/Users/ajoslin/Documents/Als/Development/production-candidate/node_modules/@babel/parser/lib/index.js:10954:23)
(node:28659) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
at emitDeprecationWarning (internal/process/promises.js:180:11)
at processPromiseRejections (internal/process/promises.js:249:13)
at processTicksAndRejections (internal/process/task_queues.js:94:32)
✨ Done in 5.98s.