nexus-plugin-prisma: Enums cannot be exposed via model

Enums work well now both for mutations and queries.

However, the typegen still seems to be missing something.

In the definition of the field (t.model.myfield), I get the following error:

ERROR: No subset types are available. Please make sure that one of your GraphQL type is a subset of your t.model('<ModelName>')

Screenshot: Screenshot 2019-09-03 at 07 17 45

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 36 (20 by maintainers)

Commits related to this issue

Most upvoted comments

@homerjam it seems like restarting the dev script worked for me. Ctrl + C then yarn dev / npm run dev

This error still seems to come up for me (nexus@0.12.0 / nexus-prisma@0.12.0). Was there a solution?

Here is a repo: https://github.com/iherger/prisma2-enum

Steps to reproduce:

git clone https://github.com/iherger/prisma2-enum.git
cd prisma2-enum
yarn install
code src/index.ts

Then you should see the error in the screenshot above.

@jasonkuhrt thanks for the reply and explanation, I will put some effort into trying it out with my current app and see if I run into any issues!

We determined that this issue is indeed resolved and that it was another issue leading to the most recent rash of problems.

@AbdusamadTurdiev What version of nexus-prisma are you using? See the example in this repo if you haven’t already.

I couldn’t find nexus-prisma in project’s package-lock.json and also there’s no package-lock.json in global prisma2 folder

@shoaibsharif thanks for the clarification, yeah this issue should be fixed on the next release.

The issue with users crafting their own enum is not so much how they do it, but rather the fact that with the current architecture, I’m pretty sure we have no way to know whether the user crafted its own enum or not when calling nexusPrismaPlugin(). Consequently, we’d end up with duplicate types.

We used to do have that information by wrapping the nexus SchemaBuilder, but we no longer can do that since we removed the makePrismaSchema function to simplify the surface API

One way would be to add another required property to nexusPrismaPlugin which would be the same types passed to makeSchema