Skip to content

Documentation is incorrectly inferred for arguments #10205

@bigtimebuddy

Description

@bigtimebuddy

Which packages are impacted by your issue?

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

Describe the bug

Here's a basic example of codegen two TS schemas. You can see that QueryColorAllArgs is incorrectly documented. Unclear why it's getting the Query documentation (4) from version.ts.

colors.ts

export default gql`
  "1. Queries for retrieving colors"
  type Query {
    "2. Returns all colors"
    colors(
      "3. Filter colors by scope"
      scope: [String]
    ): [String]
  }
`;

versions.ts

export default gql`
  "4. Queries for retrieving available versions"
  type Query {
    "5. Returns all available versions"
    versions: [String]
  }
`;

types.ts

/** 4. Queries for retrieving available versions */
export type Query = {
  __typename?: 'Query';
  /** 2. Returns all colors */
  colors?: Maybe<Array<Maybe<Scalars['String']['output']>>>;
  /** 5. Returns all available versions */
  versions?: Maybe<Array<Maybe<Scalars['String']['output']>>>;
};


/** 4. Queries for retrieving available versions */
export type QueryColorsArgs = {
  scope?: InputMaybe<Array<InputMaybe<Scalars['String']['input']>>>;
};

Your Example Website or App

https://github.com/bigtimebuddy/graphql-codegen-bug

Steps to Reproduce the Bug or Issue

  1. Clone repo (https://github.com/bigtimebuddy/graphql-codegen-bug)
  2. Run npm install
  3. Run npm test
  4. See src/generated/types.ts

Expected behavior

I'm expecting argument comments from the schema to get correctly assigned in the output arg types OR at show no comments. Comments are incorrect assigned from another schema.

Screenshots or Videos

No response

Platform

  • OS: macOS
  • NodeJS: v18.20.5
  • @graphql-codegen/cli version: 5.0.3
  • @graphql-codegen/typescript version: 4.1.2

Codegen Config File

overwrite: true
generates:
./src/generated/types.ts:
schema:
- "src/schemas/*.ts"
plugins:
- "typescript"

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions