'typegraphql-prisma: Unable to infer GraphQL type from TypeScript reflection system
I've got an application (remix-run
) with prisma and mongodb. I would like to use typescript-prisma
to generate graphql resolvers. In my schema.prisma
, I have created a new generator
generator typegraphql {
provider = "typegraphql-prisma"
output = "path/to/generated/resolvers"
}
Then by executing the script npx prisma generate
, I generate the prisma client and all graphql resolvers from my prisma schema. But every time I try to generate a (in-memory) graphql schema, I get the above error. This is the code I try to run:
import { resolvers } from "path/to/generated/resolvers"; // <-- this file fails with above error
...
const schema = await buildSchema({
resolvers,
});
Here is my tsconfig.json
:
{
"include": ["remix.env.d.ts", "**/*.ts", "**/*.tsx"],
"compilerOptions": {
"lib": ["DOM", "DOM.Iterable", "ES2019", "esnext.asynciterable"],
"esModuleInterop": true,
"jsx": "react-jsx",
"moduleResolution": "node",
"resolveJsonModule": true,
"target": "ES2019",
"strict": true,
"paths": {
"~/*": ["./app/*"]
},
"noEmit": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": false,
}
}
Solution 1:[1]
Use npx prisma migrate dev
This command generates the Prisma client that will include the latest changes and also updated typegraphql
resolvers. Then you will be able to import the resolvers.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mrcreamio |