Prisma2 with nexus - No subset types are available error


#1

I’ve been using prisma2 with nexus, and I got this error when trying to exposing role column (which is enum).

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

here’s my code exposing the User schema
let User = objectType({
name: ‘User’,
definition(t) {
t.model.id();
t.model.role();
},
});

here’s my schema
model User {
id String @default(cuid()) @id @unique
email String @unique
name String?
role Role @default(USER)
createdAt DateTime @default(now())
}

I’m not really familiar with some of the new syntax of prisma2, some suggestions might be helpful. Thanks a lot!


#2

DId you find a fix for this?


#3

Hey, have you figured it out?


#4

I’m having the same issue. Anybody else having any luck implementing enum values on a model?


#5

Also experiencing this issue


#6

Same here, not possible to include any enum in query.

query{
  findOneProfile(where:{id: 0})
  {
    name,
    gender
  }
}

Error:

{
  "errors": [
    {
      "message": "photon[mapping.plural].findOne(...)[graphqlField.name] is not a function",
      "locations": [
        {
          "line": 4,
          "column": 5
        }
      ],
      "path": [
        "findOneProfile",
        "gender"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "TypeError: photon[mapping.plural].findOne(...)[graphqlField.name] is not a function",
            "    at fieldOpts.resolve (/Users/DC-BT/Documents/Projects/necom/server/node_modules/@generated/nexus-prisma/index.js:575:112)",
            "    at field.resolve (/Users/DC-BT/Documents/Projects/necom/server/node_modules/apollo-server-core/node_modules/graphql-extensions/src/index.ts:274:18)",
            "    at resolveFieldValueOrError (/Users/DC-BT/Documents/Projects/necom/server/node_modules/graphql/execution/execute.js:503:18)",
            "    at resolveField (/Users/DC-BT/Documents/Projects/necom/server/node_modules/graphql/execution/execute.js:470:16)",
            "    at executeFields (/Users/DC-BT/Documents/Projects/necom/server/node_modules/graphql/execution/execute.js:311:18)",
            "    at collectAndExecuteSubfields (/Users/DC-BT/Documents/Projects/necom/server/node_modules/graphql/execution/execute.js:747:10)",
            "    at completeObjectValue (/Users/DC-BT/Documents/Projects/necom/server/node_modules/graphql/execution/execute.js:737:10)",
            "    at completeValue (/Users/DC-BT/Documents/Projects/necom/server/node_modules/graphql/execution/execute.js:626:12)",
            "    at /Users/DC-BT/Documents/Projects/necom/server/node_modules/graphql/execution/execute.js:528:16",
            "    at processTicksAndRejections (internal/process/task_queues.js:89:5)"
          ]
        }
      }
    }
  ],
  "data": {
    "findOneProfile": null
  }
}

ObjectType:

export const Profile = objectType({
    name: "Profile",
    definition(t) {
        t.model.name()
        t.model.gender()
        t.model.searches()
    }
});

export const Gender = enumType({
    name: "Gender",
    members: photon.Gender
});

Schema:

model Profile {
  id                 Int            @id
  name               String         @unique
  gender             Gender         @default(Male)
  searches           Gender         @default(Female)
}

enum Gender {
  Male
  Female
  Divers
}

#7

Can you please report this here:

Prisma 2 and the new nexus API is still in preview so there might be bugs that need to be addressed.


#8