For the following (simplified) model:
model PassType {
id String @default(cuid()) @id @unique
validityUnit PERIOD
}
enum PERIOD {
DAYS
WEEKS
MONTHS
YEARS
}
I am unable to query one or many PassTypes, e.g. the following query fails:
query {
findOnePassType(where: { id: "cjxtgcj6n0009459kmiekftik" }) {
id
validityUnit
}
}
The error produced is:
{
"data": {
"findOnePassType": null
},
"errors": [
{
"message": "photon[mapping.plural].findOne(...)[graphqlField.name] is not a function",
"locations": [
{
"line": 4,
"column": 5
}
],
"path": [
"findOnePassType",
"validityUnit"
]
}
]
}
This is with [email protected]/Nexus and Postgresql/local/Docker.
Same issue here except when Mutating
Some context
I had to remove my enumType declarations to stop errors from happening when trying to add the built in crud methods like t.crud.createOneUser as a mutation.
When I had the enums made via enumType I would get an error saying *enum* was already defined and imported as a type, check the docs for extending types when I would try to add the t.crud method.
Now the enums aren't explicitly typed out via enumType and I am able to add my mutation like t.crud.createOneUser. While the mutation appears to work I get the error photon[mapping.plural].findOne(...)[graphqlField.name] is not a function just like above in my response
Code Example
// I had to remove this enum out in order for the mutation below to work without throwing the "already defined" error
const Role = enumType({
name: 'Role',
members: ['FIRST', 'SECOND', 'THIRD'],
});
const Agency = objectType({
name: 'Agency',
definition(t) {
t.model.id();
t.model.role();
},
});
const Mutation = objectType({
name: 'Mutation',
definition(t) {
t.crud.createOneAgency({ alias: 'createAgency' });
},
});
Have the same problem, it is not possible to include enum fields in a query.
https://www.prisma.io/forum/t/prisma2-with-nexus-no-subset-types-are-available-error/7387/6
I also have the same problems with the include of enums as @nowlena get.
If I use crud, all enums and not needed inputTypes[...] are included, but I think this is another issue...
If someone can share a repro repo that would be great. I'm trying to repro but running into other issues along the way currently.
Here's a minimal reproduction repo: https://github.com/iherger/prisma2-enum (based on prisma2 init GraphQL boilerplate).
After installing, and running yarn seed, yarn start, try running
{
users {
id
type
}
}
@iherger Thanks so much, this is a huge help to me. I'll look at it tonight (EST).
@iherger following your instructions I don't make it all the way;
❯ yarn seed
yarn run v1.17.3
warning package.json: No license field
$ ts-node prisma/seed.ts
Error:
Invalid `const user1 = await photon.users.create()` invocation in /Users/jasonkuhrt/projects/oss/prismaNexus-327/prisma/seed.ts:5:36
1 import Photon from "@generated/photon";
2 const photon = new Photon();
3
4 async function main() {
→ 5 const user1 = await photon.users.create(
Reason: Error in connector: Unique constraint failed: User.email
What version of prisma2 are you using? I have:
❯ prisma2 --version
[email protected], binary version: 33e5fc84b6bd61602f8d634beb558230ca3e3054
Sorry for this, it seems I accidentally committed dev.db. So you can go straight to yarn start and then run the query.
Most helpful comment
@iherger Thanks so much, this is a huge help to me. I'll look at it tonight (EST).