typescript/graphql-nextjs/README is missing information on how to regenerate Nexus
I am not super sure, but I think if I change the schema more fundamentally I also need to generate the nexus types. Unfortunately this is not mentioned in the README, and the files itself tell me that I should not touch then.
yarn generate:nexus does not work unfortunately:
C:\Users\Jan\Documents\prisma-examples\typescript\graphql-nextjs>yarn generate:nexus
yarn run v1.22.0
$ ts-node --transpile-only pages/api
C:\Users\Jan\Documents\prisma-examples\typescript\graphql-nextjs\pages\api\index.ts:1
import { intArg, makeSchema, objectType, stringArg, asNexusMethod } from 'nexus';
^
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:720:23)
at Module.m._compile (C:\ProgramData\nvm\v12.6.0\node_modules\ts-node\src\index.ts:493:23)
at Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Object.require.extensions.<computed> [as .ts] (C:\ProgramData\nvm\v12.6.0\node_modules\ts-node\src\index.ts:496:12)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
at Object.<anonymous> (C:\ProgramData\nvm\v12.6.0\node_modules\ts-node\src\bin.ts:158:12)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
🤷♂
Hi,
I had the same problem with the gaphql-nextjs repository. If you're still having the problem try the following:
Create a file tsconfig.nexus.json
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"target": "ES5"
}
}
Change __dirname in pages/api/index.ts to process.cwd() (for reference #1543)
export const schema = makeSchema({
types: [Query, Mutation, Post, User, GQLDate],
outputs: {
- typegen: path.join(__dirname, 'nexus-typegen.ts'),
- schema: path.join(__dirname, 'schema.graphql')+
+ typegen: path.join(process.cwd(), 'nexus-typegen.ts'),
+ schema: path.join(process.cwd(), 'schema.graphql')
},
})
and change the generate:nexus script in package.json:
- "generate:nexus": "ts-node --transpile-only ./pages/api"
+ "generate:nexus": "ts-node --project ./tsconfig.nexus.json --transpile-only ./pages/api"
edit: I just realized who you are. 😁 ... Leaving it for others who run into the same problem 👍
I just realized who you are. 😁 ... Leaving it for others who run into the same problem 👍
I am exactly the right person to give this information to 😸 And thanks, one of my colleagues will hopefully be able to use your information to fix the example.
Alright, thanks. While they're at it: ts-node is missing in devDependencies
just fyi: I ditched the example because it is not (yet) using nexus-plugin-prisma And since I didn't get to run that either, I am writing graphql stuff ApolloServer old-school-style
The example has been updated to use Pothos & GraphQL Yoga. Feel free to re-open the issue if you're still running into the issue. :)