Closed ZaneH closed 3 years ago
I added makeSchema
directly to my server.ts (check "Old news" for my motivation) and ran yarn generate
:
yarn run v1.22.5
warning package.json: No license field
$ npm -s run generate:prisma && npm -s run generate:nexus
Environment variables loaded from prisma/.env
Prisma Schema loaded from prisma/schema.prisma
✔ Generated Prisma Client (version: 2.7.0) to ./../../node_modules/@prisma/client in 718ms
You can now start using Prisma Client in your code:
import { PrismaClient } from '@prisma/client'
// or const { PrismaClient } = require('@prisma/client')
const prisma = new PrismaClient()
Explore the full API: http://pris.ly/d/client
Error: It seems like you have applied rules to Mutation types but Shield cannot find them in your schema.
at generateMiddlewareFromSchemaAndRuleTree (/home/zaneh/Desktop/redacted/node_modules/graphql-shield/src/generator.ts:250:13)
at MiddlewareGenerator.generator (/home/zaneh/Desktop/redacted/node_modules/graphql-shield/src/generator.ts:293:5)
at MiddlewareGenerator.generate (/home/zaneh/Desktop/redacted/node_modules/graphql-middleware/src/generator.ts:19:17)
at middlewares.map.middleware (/home/zaneh/Desktop/redacted/node_modules/graphql-middleware/src/middleware.ts:72:25)
at Array.map (<anonymous>)
at applyMiddlewareWithOptions (/home/zaneh/Desktop/redacted/node_modules/graphql-middleware/src/middleware.ts:70:45)
at applyMiddleware (/home/zaneh/Desktop/redacted/node_modules/graphql-middleware/src/middleware.ts:129:10)
at new GraphQLServer (/home/zaneh/Desktop/redacted/node_modules/graphql-yoga/src/index.ts:137:13)
at Object.<anonymous> (/home/zaneh/Desktop/redacted/packages/backend/src/server.ts:42:16)
at Module._compile (internal/modules/cjs/loader.js:778:30)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
and the generated schema.graphql:
### This file was generated by Nexus Schema
### Do not make changes to this file directly
type Query {
ok: Boolean!
}
What in the world is happening?
So, I removed ./types/index.ts
and things started working a little bit better.
Now I'm only missing 1 type. It's the Mutation type. However, I think the issue is rooted deeper than "The Mutation file" because in all of my types, the relational t.model.<other_model>()
fields are error'ing.
In addition, I know the code in my type files is correct. It hasn't been changed since my last working commit.
I'm going to pause here. If anyone can help, I'd appreciate it
I had this issue earlier: https://github.com/graphql-nexus/nexus-plugin-prisma/issues/872
It transformed into this one
I thought I had fixed this: I didn't
I believed this to be a case of circular imports (it couldn't generate @prisma/client because a generated type couldn't be imported),
But days after that "fix" I still stumble on this error. Reopened and praying
I think...I maybe found the fix?
I had 2 PrismaClient instances. I exported the 1 in my context.ts
file, and removed the one in server.ts
. Seems to have fixed it.
How did you fix this at the end? I got the same issue out of a sudden and couldn't get things to work again, I tried different prisma clients from 2.9 up to lastest, please share your package.json if you can
How did you fix this at the end? I got the same issue out of a sudden and couldn't get things to work again, I tried different prisma clients from 2.9 up to lastest, please share your package.json if you can
Try not to import prisma
from the context.ts
. Pass it through the args. I had this problem earlier.
I honestly have no clue where this issue began. Yesterday, at some point, I started getting this error on
yarn generate
:I can't think of anything that would've caused this, but I tried rolling back to a previous (and known-to-work) commit, deleting my node_modules, and reinstalling, but I never got it back to a working state 🥳. If anyone has any info/debugging tips for this, I'm all ears
My package.json:
I've tried:
undefined
)