Extend typescript-operations to support directives for operationResultType
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:
type DemoThing {
thingV1: string! @deprecated(reason: "thingV1 is old, use thingV2")
thingV2: string!
}
which generates
export type DemoThing = {
/** @deprecated thingV1 is old, use thingV2 */
thingV1: string
thingV2: string
}
but when I make a query that includes that — e.g.
query getDemoThing {
thingV1
thingV2
}
I don't get the deprecation JSDoc. It generates:
export type GetDemoThingQuery = {
thingV1: string
thingV2: string
}
Describe the solution you'd like
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.
I am not sure I understand your problem. Could you elaborate?
@ardatan thanks, and sure:
Current setup
Ultimately I'm fetching data with the hooks generated using typescript-react-query. In the example above I'd consume the hook like this
const { data } = useGetDemoThingQuery()
the type for data will then be optional GetDemoThingQuery that doesn't have the JSDoc annotation inside it. So when in consume data?.thingV1 it's not marked as deprecated.
My wish
That the GetDemoThingQuery includes the JSDoc comment so I can set up tooling to warn me when I consume data?.thingV2
So with
export type GetDemoThingQuery = {
/** @deprecated thingV1 is old, use thingV2 */
thingV1: string
thingV2: string
}
I could get something like this and have my CI block/warn when doing frontend releases that I'm consuming something that was marked as deprecated by the API.

@dotansimha @ardatan it seems reasonable to me, please let me know if it doesn't make sense?
@larsenwork want to start working on it?
@Urigo sure, it'd speed up my process greatly with some pointers where to start 👀 — i.e. if it's in the typescript-operations package or somewhere else.
I too have just realised deprecations are missing from typescript-operations, and that any deprecations wouldn't flow from api to consumers using this tooling.
@zomble yeah, it's a bit unfortunate. However without pointers I'd be a bit hard pressed to start fixing it but I could actually dedicate some office time to it this week if given a tiny pointer or two @Urigo ? 😄