Hey gentle Prisma folks :wave:. I am currently mig...
# graphql-nexus
s
Hey gentle Prisma folks 👋. I am currently migrating from nexus framework to @nexus/schema, using nexus-plugin-prisma running on next.js. I'm almost through with the migration but I'm stuck on one point: nexus-plugin-prisma is generating types into
node_modules/@types/typegen-nexus-plugin-prisma/
automatically when running the server in dev mode. But I need it to generate these types as a build step in CI/CD (otherwise next build fails as well). I do manage to generate the
schema.graphql
and
nexus.ts
running reflection like this
npx ts-node -T ./graphql/schema/index.ts
and using the flag
shouldExitAfterGenerateArtifacts
. But during this step, the nexus-plugin-prisma files do not seem to be generated. Here my code generating the schema: https://github.com/teachen-ch/voty/blob/d525c36a0a7cff85816804e86f3b854cac480d69/graphql/makeschema.ts#L12
r
Hey @Stefan N 👋 If you want to configure the folder for the types generated, then you can do it in the
outputs
property as follows:
Copy code
export const schema = makeSchema({
  types: [allTypes],
  plugins: [nexusPrisma],
  outputs: {
    typegen: join(__dirname, 'generated', 'index.d.ts'),
    schema: join(__dirname, 'generated', 'schema.graphql'),
  },
  typegenAutoConfig: {
    sources: [
      {
        source: '@prisma/client',
        alias: 'prisma',
      },
      {
        source: join(__dirname, 'types.ts'),
        alias: 'ctx',
      },
    ],
    contextType: 'ctx.Context',
  },
})
This way your types will be generated in your build step correctly and can also commit these to source control if you wish as to skip the generation in CI/CD.
s
Thanks Ryan! This should be working indeed! Appreciate the speedy response 🙏
🙌 1
💯 1