dotansimha / graphql-code-generator

A tool for generating code based on a GraphQL schema and GraphQL operations (query/mutation/subscription), with flexible support for custom plugins.
https://the-guild.dev/graphql/codegen/
MIT License
10.84k stars 1.33k forks source link

schema-ast does not comment descriptions at the same time as including directives #6529

Open mstykow opened 3 years ago

mstykow commented 3 years ago

Describe the bug As soon as includeDirectives is set to true, the value of commentDescriptions no longer matters: comments will always be generated as docstrings.

To Reproduce

schema: schema.graphql
documents: document.graphql
generates:
  types.ts:
    plugins:
      - typescript
      - typescript-operations
  schema.generated.graphql:
    plugins:
      - 'schema-ast'
    config:
      includeDirectives: true
      commentDescriptions: true

Link to Codebox for reproduction: https://codesandbox.io/s/bold-bird-wuf3p?file=/codegen.yml

Expected behavior It is possible to include directives and comment descriptions at the same time.

Schema

type Query {
    user(id: ID!): User!
}

"""
TESTING
"""
type User {
    id: ID!
    username: String!
    email: String!
}

Environment:

ardatan commented 3 years ago

I don't see any directives in the reproduction.

mstykow commented 3 years ago

@ardatan yes, but there is a comment in the reproduction and that comment is kept as docstring although the plugin docs say that it should be converted: https://www.graphql-code-generator.com/docs/plugins/schema-ast

when you set includeDirections: false you'll see that the docstring gets correctly converted.