dotansimha / dotansimha/graphql-code-generator-community

[typescript-type-graphql] Plugin to include GQL description in TypeGraphQL decorator description

Open
#94 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

Description

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

It is mandated in our codebase that typegraphql types specify their description. GraphQL specifies a description syntax: https://spec.graphql.org/June2018/#sec-Descriptions. But those descriptions do not make it into the TypeGraphQL decorator, but instead as a code comment. I also see no option for this.

e.g.
```
"""
User description
"""
type User implements Node {
"ID for the object"
id: ID!
}
```
becomes
```
/** User description */
@TypeGraphQL.ObjectType({ implements: Node })
export class User extends Node {
__typename?: 'User';
/** ID for the object */

@TypeGraphQL.Field(type => TypeGraphQL.ID)
id!: Scalars['ID'];
};
```
I would like it to become
```
@TypeGraphQL.ObjectType({
description: "User description",
implements: Node
})
export class User extends Node {
__typename?: 'User';

@TypeGraphQL.Field(type => TypeGraphQL.ID, {description: "ID for the object"})
id!: Scalars['ID'];
};
```

**Describe the solution you'd like**
Add a plugin option such as `includeDescriptionInDeclaration` that will put the description here. Defaults to false for backwards compat. TBD whether or not the code comment should also be included. I don't see why not.

**Describe alternatives you've considered**
I don't see an alternative that makes more sense than putting the description in right when it is compiled.

**Additional context**
None. Other than I love this project.

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.