Cauen / prisma-generator-pothos-codegen

The fastest way to create a fully customizable CRUD Graphql API from Prisma Schema.
https://www.npmjs.com/package/prisma-generator-pothos-codegen
95 stars 16 forks source link

builderImporters ignored? #68

Closed m1212e closed 2 months ago

m1212e commented 4 months ago

Hi,

this is my config:

module.exports = {
  /** Input type generation config */
  inputs: {
    outputFilePath: "./prisma/graphql/pothosCrud/inputs.ts",
    /** How to import the Prisma namespace. Default: `"import { Prisma } from '.prisma/client';"` */
    prismaImporter: "import { Prisma } from '../../client';",
    /** Map all Prisma fields with "@id" attribute to Graphql "ID" Scalar.
     *
     * ATTENTION: Mapping non String requires a conversion inside resolver, once GraphQl ID Input are coerced to String by definition. Default: false */
    mapIdFieldsToGraphqlId: true,
  },
  crud: {
    outputDir: "./prisma/graphql/pothosCrud/",
    /** How to import the Prisma namespace at the objects.ts file. Default `"import { Prisma } from '.prisma/client';"`. Please use "resolverImports" to import prismaClient at resolvers. */
    prismaImporter: "import { Prisma } from '../../../client';",
    /** How to call the prisma client. Default `'_context.prisma'` */
    prismaCaller: "db",
    /** Any additional imports you might want to add to the resolvers (e.g. your prisma client). Default: `''` */
    resolverImports: "\nimport { db } from '../../../../db';",
    /** Caution: This delete the whole folder (Only use if the folder only has auto generated contents). A boolean to delete output dir before generate. Default: False */
    deleteOutputDirBeforeGenerate: true,
  },
  global: {
    builderImporters: "import { builder } from '../builder';"
  }
};

but the builder import is not adjusted:

import * as Inputs from '../inputs';
import { builder } from '../../../../builder';
import {
  definePrismaObject,
  defineFieldObject,
  defineRelationFunction,
  defineRelationObject,
} from '../utils';

export const CommitteeMemberObject = definePrismaObject('CommitteeMember', {
  description: 'A user's membership in a committee, providing them with a role in the committee',
  findUnique: ({ id }) => ({ id }),
  fields: (t) => ({
    id: t.field(CommitteeMemberIdFieldObject),
    committee: t.relation('committee', CommitteeMemberCommitteeFieldObject),
    committeeId: t.field(CommitteeMemberCommitteeIdFieldObject),
    user: t.relation('user', CommitteeMemberUserFieldObject),
    userId: t.field(CommitteeMemberUserIdFieldObject),
    speakerLists: t.relation('speakerLists', CommitteeMemberSpeakerListsFieldObject(t)),
    delegation: 
...

Am I doing something wrong?

Cauen commented 2 months ago

Sorry for the delay in responding, busy days D:

Please use global.builderLocation instead. Documentation added to readme and old documentation removed.