Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript/graphql-nextjs/README is missing information on how to regenerate Nexus #1658

Closed
janpio opened this issue Mar 28, 2020 · 4 comments
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug.

Comments

@janpio
Copy link
Contributor

janpio commented Mar 28, 2020

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.

🤷‍♂

@ankri
Copy link

ankri commented Apr 10, 2020

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 👍

@janpio
Copy link
Contributor Author

janpio commented Apr 10, 2020

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.

@ankri
Copy link

ankri commented Apr 10, 2020

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

@janpio janpio added bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug. labels Jul 24, 2020
@ruheni
Copy link
Contributor

ruheni commented Feb 1, 2023

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. :)

@ruheni ruheni closed this as completed Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

3 participants