dotansimha / dotansimha/graphql-code-generator

Extend typescript-operations to support directives for operationResultType

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

Description

**Is your feature request related to a problem? Please describe.**

In my frontend I'm consuming a schema that uses @deprecated directives. Ultimately I'd like to get eslint warnings if I'm consuming a deprecated value using https://github.com/gund/eslint-plugin-deprecation#setup

Example code:

```GRAPHQL
type DemoThing {
thingV1: string! @deprecated(reason: "thingV1 is old, use thingV2")
thingV2: string!
}
```

which generates

```ts
export type DemoThing = {
/** @deprecated thingV1 is old, use thingV2 */
thingV1: string
thingV2: string
}
```
but when I make a query that includes that — e.g.

```GRAPHQL
query getDemoThing {
thingV1
thingV2
}
```

I don't get the deprecation JSDoc. It generates:

```ts
export type GetDemoThingQuery = {
thingV1: string
thingV2: string
}
```

---

**Describe the solution you'd like**

```diff
export type GetDemoThingQuery = {
+ /** @deprecated thingV1 is old, use thingV2 */
thingV1: string
thingV2: string
}
```

---

**Describe alternatives you've considered**

None 😅

---

**Additional context**

I'm using

```
plugins:
- typescript
- typescript-operations
- typescript-react-query
```

I'd love to help out implementing this if deemed valuable/doable. Particularly if I get a few pointers.

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.