dotansimha / dotansimha/graphql-code-generator

Documentation is incorrectly inferred for arguments

Open
#10,205 0 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/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**

```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**

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

**types.ts**

```ts
/** 4. Queries for retrieving available versions */
export type Query = {
__typename?: 'Query';
/** 2. Returns all colors */
colors?: Maybe>>;
/** 5. Returns all available versions */
versions?: Maybe>>;
};

/** 4. Queries for retrieving available versions */
export type QueryColorsArgs = {
scope?: InputMaybe>>;
};
```

### 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_

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.