-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Description
Which packages are impacted by your issue?
@graphql-codegen/graphql-modules-preset
Describe the bug
If you set encapsulateModuleTypes: prefix
and add a custom scalar, the generated code will look like this:
export interface Test_Resolvers {
DateTime?: Test_core.Resolvers['DateTime'];
};
The generated code does not contain the name Test_core
, which appears to be a bug.
Your Example Website or App
Steps to Reproduce the Bug or Issue
- Go to TypeScript Playground.
- Paste the existing snapshot test. (https://github.com/dotansimha/graphql-code-generator/blob/master/packages/presets/graphql-modules/tests/__snapshots__/builder.spec.ts.snap#L76-L142)
- A type error occurs (
Cannot find namespace 'Test_core'
).
Expected behavior
the correctly modified Snapshot test: tonyfromundefined@eb4e4b3#diff-3dab381552e68d80f5b1e3b996c6a9a6b05e5a6b29cc670aa171c66a49e9c2d5
Screenshots or Videos
No response
Platform
- OS: macOS
- NodeJS: 24.4.1
graphql
version: 16.11.0@graphql-codegen/graphql-modules-preset
version(s): 4.0.17
Codegen Config File
// codegen.ts
import type { CodegenConfig } from "@graphql-codegen/cli";
const config: CodegenConfig = {
schema: "./src/graphql/**/typedefs/*.graphql",
generates: {
"./src/graphql/": {
preset: "graphql-modules",
presetConfig: {
baseTypesPath: "./__generated__/graphql.ts",
importBaseTypesFrom: "../../__generated__/graphql",
filename: "__generated__/module-types.ts",
encapsulateModuleTypes: "prefix",
},
plugins: ["typescript", "typescript-resolvers"],
config: {
contextType: "../Context#Context",
enumsAsTypes: true,
mapperTypeSuffix: "Type",
useTypeImports: true,
mappers: {
// ...
},
},
},
"./src/graphql/__generated__/schema.graphql": {
plugins: ["schema-ast"],
},
},
};
export default config;
Additional context
I've already fixed this issue in my codebase with a patch (1 line). I've forked it and posted the modified commit to my github so you can understand the changes. I'd be happy to submit a PR if you'd like. Thanks!
Metadata
Metadata
Assignees
Labels
No labels