Closed elritz closed 1 year ago
Hi @elritz
Can you please share a minimal, reproducible example? in a Github repo?
Anyway, do these issues happen in your environment when using the sample project?
@elritz I had the same issue, I fixed it by going into the file where the BatchPayload
object is generated and fixed the prisma import.
@DennisMG
Does setting inputs.prismaImporter
at config.js
resolve this issue?
{
/** Input type generation config */
inputs?: {
/** Create simpler inputs for easier customization and ~65% less generated code. Default: `false` */
simple?: boolean;
/** How to import the Prisma namespace. Default: `"import { Prisma } from '.prisma/client';"` */
>> prismaImporter?: string;
/** How to import the Pothos builder. Overrides global builderImporter config. Default: `"import { builder } from './builder';"` */
builderImporter?: string;
/** Path to generate the inputs file to from project root. Default: `'./generated/inputs.ts'` */
outputFilePath?: string;
/** List of excluded scalars from generated output */
excludeScalars?: string[];
/** A function to replace generated source. Combined with global replacer config */
replacer?: Replacer<'inputs'>;
};
@Cauen This is my config file. I have prismaImporter set for both crud and inputs. but the import is missing from all the files, seems like is ignoring the setting.
module.exports = {
inputs: {
simple: true,
outputFilePath: "./graphql/__generated__/inputs.ts",
prismaImporter: `import prisma from "../../../../../lib/prisma"`,
},
crud: {
outputDir: "./graphql/__generated__/",
inputsImporter: `import * as Inputs from '../inputs';`,
prismaImporter: `import prisma from "../../../../../lib/prisma"`,
prismaCaller: "prisma",
disabled: false,
},
global: {
builderImporter: `import { builder } from '../../pages/api/builder';`,
},
}
I managed to get it working. Now my config file looks like this:
module.exports = {
inputs: {
outputFilePath: "./graphql/__generated__/inputs.ts",
prismaImporter: `import { Prisma } from "@prisma/client";`,
prismaCaller: "_context.prisma",
},
crud: {
outputDir: "./graphql/__generated__/",
inputsImporter: `import * as Inputs from '../inputs';`,
prismaImporter: `import { Prisma } from "@prisma/client";`,
prismaCaller: "_context.prisma",
disabled: false,
},
global: {
builderImporter: `import { builder } from '../../pages/api/builder';`,
},
}
I added the prismaCaller: "_context.prisma",
and now I'm sending the db connection through the server context like this:
const server = new ApolloServer({
schema,
})
export default startServerAndCreateNextHandler(server, {
context: async (req, res) => ({ prisma }),
})
Closing the issue, once we have the probable solution Thanks @DennisMG
Check out your generated files folder:
I am getting this error, only for these files
What this means is I cant build a project. Let me know if you get the same error I have updated the packages but i also downgraded them to make sure, also I am using pnpm.