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

sdlInputs not working because of changes in prisma. #283

Closed
joaquimnetocel opened this issue Sep 28, 2022 · 2 comments
Closed

sdlInputs not working because of changes in prisma. #283

joaquimnetocel opened this issue Sep 28, 2022 · 2 comments

Comments

@joaquimnetocel
Copy link

The "sdlInputs.ts" is not working because of changes in prisma 4.

As pointed here, Prisma no longer exports Prisma.dmmf.schema into the generated Prisma Client.

I don't know if it helps, but the new getDMMF function can be imported with:

import { getDMMF } from "@prisma/internals/dist/engine-commands";

I thought about making a pull request, but as getDMMF is an asynchronous function, I don't know the best way to solve the problem.

@zakariamofaddel
Copy link

zakariamofaddel commented Oct 21, 2022

I temporarily solved by manually generating the dmmf with this function (you can automate this to happen before nexus generation with a script command in package.json):

import { getDMMF } from "@prisma/internals"
import fs from "fs"

const run = async () => {
  const schema = fs.readFileSync(`${__dirname}/../../../prisma/schema.prisma`, {
    encoding: "utf-8",
  })
  const dmmf = await getDMMF({ datamodel: schema })

  fs.writeFileSync(`${__dirname}/dmmf.json`, JSON.stringify(dmmf, null, 2))
}

run()

and then passing the result to the paljs plugin settings:

// This file was generated from the previous step
import dmmfJSON from "./dmmf.json"

const nexusSchema = makeSchema({
  types: myGeneratedTypes,
  plugins: [
    paljs({
    dmmf: [JSON.parse(JSON.stringify(dmmfJSON))],
    }),
  ],
  outputs: {
    ...
  },
  contextType: {
    ...
  },
})

This is just a temporary fix while hopefully paljs gets upgraded.

@AhmedElywa
Copy link
Collaborator

This issue request is in #284

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants