dotansimha / dotansimha/graphql-code-generator

Generated `TypedDocumentString` generic params improvement

Open
#9,545 0 comments 2 reactions 0 assignees View on GitHub
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.

Currently, generated code including `TypedDocumentString` contains ugly and seemingly unnecessary type assertions. For example:

```ts
export const ProductsGetListDocument = new TypedDocumentString(`
query ProductsGetList {
products(first: 10) {
id
name
}
}
`) as unknown as TypedDocumentString;
```

### Describe the solution you'd like

The assertion can be omitted and generic parameters could be added directly after `new TypedDocumentString` like this:

```ts
export const ProductsGetListDocument = new TypedDocumentString(`
query ProductsGetList {
products(first: 10) {
id
name
}
}
`);
```

> **Note**
> I have a [very rough version of this implemented on my fork](https://github.com/dotansimha/graphql-code-generator/compare/master...typeofweb:graphql-code-generator:TypedDocumentString?expand=1). Could open a PR.

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

It's not related to a problem _per se_ but generated code could be made prettier and more concise.

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.