dotansimha / dotansimha/graphql-code-generator

DocumentTypeDecoration Not Imported inside graphql.ts when there is no document

Open
#10,176 7 comments 10 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Which packages are impacted by your issue?

@graphql-codegen/cli, @graphql-codegen/client-preset

### Describe the bug

Package json
```json
{
"name": "graph-communication-network",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@graphql-codegen/import-types-preset": "^3.0.0",
"graphql": "^16.9.0"
},
"devDependencies": {
"@graphql-codegen/cli": "5.0.3",
"@graphql-codegen/client-preset": "4.4.0",
"@graphql-codegen/introspection": "4.0.3",
"@graphql-codegen/typescript": "4.1.0",
"@graphql-codegen/typescript-document-nodes": "4.0.10"
},
"scripts": {
"codegen": "graphql-codegen --config codegen.ts"
}
}
```

when we run codegen everything gets generated but graphql has one type issue
```
Cannot find name 'DocumentTypeDecoration'.
```

![image](https://github.com/user-attachments/assets/eec89734-2d23-44c9-9867-6c407e83b97f)

### Your Example Website or App

n/a

### Steps to Reproduce the Bug or Issue

when we run codegen everything gets generated but graphql has one type issue
```
Cannot find name 'DocumentTypeDecoration'.
```

### Expected behavior

It think generation should import/generate it.
Looking at local `/examples` we can see typescript example here https://github.com/dotansimha/graphql-code-generator/blob/master/examples/typescript-esm/src/gql/graphql.ts which imports it at the top, and I'm unsure why it is not included

### Screenshots or Videos

_No response_

### Platform

- OS: [e.g. macOS, Windows, Linux]
- NodeJS: v20.14.0
- `graphql` version: 16.9.0
- `@graphql-codegen/*` 5.0.3

### Codegen Config File

```ts
import type { CodegenConfig } from "@graphql-codegen/cli";

const config: CodegenConfig = {
overwrite: true,
schema: "http://localhost:9000/graphql",
documents: "src/**/*.tsx",
ignoreNoDocuments: true,
generates: {
"src/gql/": {
preset: "client",
config: {
documentMode: "string",
onlyEnumTypes: false,
onlyOperationTypes: false,
useTypeImports: true,
},
plugins: [
]
},
"./graphql.schema.json": {
plugins: ["introspection"]
},
"./schema.graphql": {
plugins: ["schema-ast"],
config: {
includeDirectives: true
}
}
}
};

export default config;
```

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.