With `prisma-nexus`, how do you expose enums?
# orm-help
l
With
prisma-nexus
, how do you expose enums?
The hidden
prismaEnumType
w
You should use prismaEnumType only to customize prisma enums. Otherwise, just use nexus enumType
l
Hey thanks @weakky! I'm struggling on the syntax. If I want to expose
Prisma Enum
defined in Prisma, I would... ?
Copy code
const PrismaEnum = enumType({
  name: "PrismaEnum"
});
And that will do it?
w
Copy code
prismaEnumType({
  name: 'PrismaEnum',
  members: ['value1', 'value2']
})
Just a reminder though: You don’t need to declare it to have it exposed
This is only useful if you want to hide members of the enum you defined in your datamodel
l
Nexus is complaining that my Enums aren't imported from Prisma. There's something I'm not getting. That's normal. 🙂
w
To what object type is that enum linked to ?
Nexus-prisma works as follow: For all types that are missing, it’ll go look into the prisma schema and add it for you to your graphql api
l
Ok, got it, thank you! The problem was sloppy code. I'm refactoring an old project that stitches in a third GraphQL API (that I also control). I `graphql-import`ed all Prisma Enums, but as the project evolved, those Enums should have been moved out of Prisma and into the server. But I orphaned them in Prisma. That's why I was so confused... so to answer your question, they don't belong to a Prisma object type 🙂
🙌 1