graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

`@deprecated` directive on root resolver arguments does not get reflected in generated types

Open lucaslim opened this issue 1 year ago • 1 comments

Which packages are impacted by your issue?

@graphql-codegen/cli, @graphql-codegen/typescript

Describe the bug

Adding a @deprecated directive on the resolver arguments itself, does not show up in the generated types. Based on the GraphQL spec, @deprecated is supported on the resolver's argument.

Your Example Website or App

https://the-guild.dev/graphql/codegen - Using the codegen playground

Steps to Reproduce the Bug or Issue

This can be replicated in the graphql codegen playground.

  • Go to https://the-guild.dev/graphql/codegen
  • Select Schema Types

schema.graphql

scalar Date

schema {
  query: Query
}

type Query {
  user(id: ID!, oldUserId: ID @deprecated(reason: "this field should be deprecated")): User
}

type User {
  id: ID!
  username: String!
  email: String!
}

codegen.yml

generates:
  types.ts:
    plugins:
      - typescript

autogenerated types.ts

export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
  ID: { input: string; output: string; }
  String: { input: string; output: string; }
  Boolean: { input: boolean; output: boolean; }
  Int: { input: number; output: number; }
  Float: { input: number; output: number; }
  Date: { input: any; output: any; }
};

export type Query = {
  __typename?: 'Query';
  user?: Maybe<User>;
};


export type QueryUserArgs = {
  id: Scalars['ID']['input'];
  oldUserId?: InputMaybe<Scalars['ID']['input']>;
};

export type User = {
  __typename?: 'User';
  id: Scalars['ID']['output'];
  username: Scalars['String']['output'];
  email: Scalars['String']['output'];
};

Expected behavior

I should expect this type to be generated instead

expected types.ts

export type Maybe<T> = T | null;
export type InputMaybe<T> = Maybe<T>;
export type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };
export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };
export type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };
export type Incremental<T> = T | { [P in keyof T]?: P extends ' $fragmentName' | '__typename' ? T[P] : never };
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
  ID: { input: string; output: string; }
  String: { input: string; output: string; }
  Boolean: { input: boolean; output: boolean; }
  Int: { input: number; output: number; }
  Float: { input: number; output: number; }
  Date: { input: any; output: any; }
};

export type Query = {
  __typename?: 'Query';
  user?: Maybe<User>;
};


export type QueryUserArgs = {
  id: Scalars['ID']['input'];
  /** @deprecated this field should be deprecated */
  oldUserId?: InputMaybe<Scalars['ID']['input']>;
};

export type User = {
  __typename?: 'User';
  id: Scalars['ID']['output'];
  username: Scalars['String']['output'];
  email: Scalars['String']['output'];
};

Screenshots or Videos

image

Platform

  • OS: macOS 13.3.1
  • graphql version: whatever version is on the playground
  • @graphql-codegen/typescript version(s): whatever version is on the playground
  • @graphql-codegen/cli version(s): whatever version is on the playground

Codegen Config File

generates: types.ts: plugins: - typescript

Additional context

No response

lucaslim avatar Aug 11 '23 14:08 lucaslim