graphql-code-generator: Docblocks disappeared in versions ^1.10.0
Describing the bug
In versions <1.10.0, types generated by the typescript plugin had docblocks with descriptions coming from the API.
After upgrading to latest, those comments are missing from the generated file. I found that this happens since 1.10.0 but nothing in the Releases tab or issues seems to mention any change about this.
My diff looks like this, for hundreds of types:
-/** A connection to a list of items. */
export type AppletConnection = {
readonly __typename?: 'AppletConnection',
- /** Total object count. */
readonly count: Scalars['Int'],
- /** Information to aid in pagination. */
readonly pageInfo: PageInfo,
- /** Information to aid in pagination. */
readonly edges: ReadonlyArray<AppletEdge>,
};
-/** An edge in a connection. */
export type AppletEdge = {
readonly __typename?: 'AppletEdge',
- /** The item at the end of the edge */
readonly node: Applet,
- /** A cursor for use in pagination */
readonly cursor: Scalars['String'],
};
-/** List of items with pagination. */
export type AppletPagination = {
readonly __typename?: 'AppletPagination',
- /** Total object count. */
readonly count?: Maybe<Scalars['Int']>,
- /** Array of objects. */
readonly items?: Maybe<ReadonlyArray<Maybe<Applet>>>,
- /** Information to aid in pagination. */
readonly pageInfo: PaginationInfo,
};
Of course, I verified that the descriptions are still in the API, and when I’m coming back to versions prior to ^1.10.0, doc blocks are back.
To reproduce
My codegen.yml config file:
schema: "http://localhost:9000/graphql"
generates:
projects/lib.browser.{redacted}/graphql.generated.ts:
documents: projects/lib.browser.{redacted}/**/*.graphql
plugins:
- add: |
// /!\ This file is auto-generated by graphql-code-generator. Do not edit by hand.
// tslint:disable
// ...line above is mainly for IDE support, see webpack configs where this file is excluded
- typescript
- typescript-operations
- typescript-apollo-angular
config:
immutableTypes: true
scalars:
MongoID: string
JSON: any
Date: string
JSONObject: '{ [key: string]: any }'
Success: "'success'"
Dependencies (managed by yarn, lock file confirms latest version is installed) :
{
"@graphql-codegen/add": "^1.11.0",
"@graphql-codegen/cli": "^1.11.0",
"@graphql-codegen/typescript": "^1.11.0",
"@graphql-codegen/typescript-apollo-angular": "^1.11.0",
"@graphql-codegen/typescript-operations": "^1.11.0"
}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 9
- Comments: 22 (6 by maintainers)
Commits related to this issue
- Force old graphql-codegen version (comment bug) https://github.com/dotansimha/graphql-code-generator/issues/3249 — committed to kontist/js-sdk by johannespfeiffer 4 years ago
any update on this? I think we have a pretty solid repro here ⬆️
@ardatan https://codesandbox.io/s/solitary-butterfly-yhmfn
in
index.js:./codegen.ymldiff between 1.9.1 and 1.12.1:
./graphql.types.ts./graphql.schema.jsonFixed in v1.13.2
@dotansimha I tried it. The generated schema has documentations now. Thanks!
The GraphQL framework I’m using comes with a way to dump the schema to JSON. When I run the codegen against that JSON file, I get docblocks. When I run the codegen against a URL, I don’t get docblocks.
This indicates that maybe there is a problem with the introspection query that is being sent to the server? This is the query that is being run when I dump the schema to JSON: https://github.com/absinthe-graphql/absinthe/blob/v1.4.16/priv/graphql/introspection.graphql.
https://github.com/ardatan/graphql-toolkit/blob/master/packages/loaders/url/tests/url-loader.spec.ts We have tests for URL endpoint as well. It has descriptions and a custom schema declaration to be specific.
I’d love to, but I am swamped at the moment… I can share my codegen config file, if that’s of any help:
And I have comments attached to my fields in my schema e.g.
Descriptions are missing from both
graphql.schema.json(as “description” property of an entity) andservice.graphql.ts(as docblock comments, as @toverux reported in the first post):It seems that “descriptions” are not being retrieved properly from an url endpoint. The last version I had this working was 1.9.1, so I am staying on that for the time being.