Closed lensbart closed 6 months ago
Hello @lensbart !
Thanks for using the preset, and apologies for the delayed response.
I've tried to re-create your setup using this example Codesandbox:
tsconfig.json
with alias path to src/__generated__/prisma/index
"src/schema": defineConfig({
emitLegacyCommonJSImports: false,
resolverMainFile: "./__generated__/resolvers.ts",
resolverTypesPath: "./__generated__/types.ts",
typeDefsFilePath: "./__generated__/typeDefs.ts",
tsConfigFilePath: "./tsconfig.json",
typesPluginsConfig: {
contextType: "../../index#ResolverContext",
},
}),
base/schema.graphql
and base/schema.mappers.ts
annotations/annotations.graphql
and annotations/annotations.mappers.ts
block/block.graphql
and block/block.mappers.ts
inline/inline.graphql
and inline/inline.mappers.ts
export type { Block as BlockMapper } from "src/__generated__/prisma/index";
export type { Inline as InlineMapper } from "../../__generated__/prisma/index";
The generated type file is correctly importing the mapper interfaces:
The only thing I haven't tried is setting up your config in a monorepo (which seems to be your real setup). However, I have an app that uses codegen in an Nx monorepo and it is working fine too.
Do you have an example where I could check out to debug? 🙂
Sorry for the late response — I can’t easily provide an example, because the project I’m working on is closed source. Feel free to close this issue, I have resolved it on my end by putting all mappers in a single schema.mappers.ts
file.
Thanks @lensbart !
Hello,
First of all, thanks for developing the server preset. It allowed me to remove large chunks of boilerplate code.
Not entirely sure how to narrow down this bug, but I have the following setup:
and a couple of modules:
annotation
,base
,block
andinline
. If I have the following mapper files (all paths below are insidesrc/schema
):annotation/annotation.mappers.ts
base/base.mappers.ts
block/block.mappers.ts
inline/inline.mappers.ts
then only
annotation.mappers.ts
andblock.mappers.ts
get detected and imported into the generatedtypes.ts
file.If I rename these files to:
annotation/annotation.mappers.ts
base/schema.mappers.ts
block/block.mappers.ts
inline/inline.mappers.ts
then all except for
inline.mappers.ts
are imported intotypes.ts
If I rename these files to:
annotation/schema.mappers.ts
base/schema.mappers.ts
block/schema.mappers.ts
inline/schema.mappers.ts
then only the second file gets imported into the generated
types.ts
file.The only thing I changed to achieve these different results is the filename. Each of these files contain a single statement, in the form of
None of these exports have overlapping names.
Hope this helps!