dotansimha / dotansimha/graphql-code-generator

client-preset does not generate types for deprecated input fields when using introspection

Open
#9,354 2 comments 0 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/client-preset

### Describe the bug

The following type in SDL
```gql
input MyInput {
foo: Boolean
"""
Will be removed later
"""
bar: Boolean @deprecated(reason: "Will be removed later")
}
```
Generates the following TS types using the `client-preset`
```ts
export type TemplatesFilter = {
foo?: InputMaybe;
};
```

### Your Example Website or App

https://codesandbox.io/p/sandbox/muddy-leaf-wuqws1?file=%2Frenovate.json&selection=%5B%7B%22endColumn%22%3A37%2C%22endLineNumber%22%3A12%2C%22startColumn%22%3A37%2C%22startLineNumber%22%3A12%7D%5D

### Steps to Reproduce the Bug or Issue

1. Open code sandbox (will run apollo server with schema)
2. Start a new command `yarn codegen:watch`
3. Inspect the `types/graphql.ts` `UserFilter` type
4. deprecated field is not there

### Expected behavior

The generated TS types should include deprecated fields

### Screenshots or Videos

_No response_

### Platform

- OS: macOS
- NodeJS: 18
- `graphql` version: 16
- `@graphql-codegen/cli` version(s): 3.3.1
- `@graphql-codegen/client-preset` version(s): 3.0.1

### Codegen Config File

```ts
import { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
overwrite: true,
ignoreNoDocuments: true, // for better experience with the watcher
generates: {
'lib/gql/': {
preset: 'client',
schema: {
'http://localhost:4040/graphql': {
headers: {
Authorization: 'Bearer XXXXXXXX',
},
},
},
documents: ['{pages,lib,components}/**/*.{ts,tsx,js,jsx}'],
},
},
config: {
namingConvention: 'keep',
scalars: {
DateTime: 'string',
JSON: 'unknown',
Upload: 'unknown',
Time: 'string',
Date: 'string',
Long: 'number',
Url: 'string',
},
},
}

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.