Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.13.1 -> 1.13.2 removes comments from schema #3825

Closed
SimenB opened this issue Apr 7, 2020 · 4 comments
Closed

1.13.1 -> 1.13.2 removes comments from schema #3825

SimenB opened this issue Apr 7, 2020 · 4 comments
Labels
core Related to codegen core/cli waiting-for-answer Waiting for answer from author

Comments

@SimenB
Copy link
Contributor

SimenB commented Apr 7, 2020

Describe the bug
Comments from the schema are gone in the generated code.

To Reproduce
Steps to reproduce the behavior:

  1. My GraphQL schema:
type Query {
  # A name!
  name: String!
}
  1. My GraphQL operations:
# none
  1. My codegen.yml config file:
generates:
  ./gqltypes.ts:
    schema: ./schema.graphql
    plugins:
      - 'typescript'

Expected behavior
1.13.1 generates comments

export type Maybe<T> = T | null;
/** All built-in and custom scalars, mapped to their actual values */
export type Scalars = {
  ID: string;
  String: string;
  Boolean: boolean;
  Int: number;
  Float: number;
};

export type Query = {
   __typename?: 'Query';
  /** A name! */
  name: Scalars['String'];
};

1.13.2 does not

diff --git i/gqltypes.ts w/gqltypes.ts
index 41d3dfebf..3172daf0e 100644
--- i/gqltypes.ts
+++ w/gqltypes.ts
@@ -10,6 +10,5 @@ export type Scalars = {
 
 export type Query = {
    __typename?: 'Query';
-  /** A name! */
   name: Scalars['String'];
 };

Environment:

  • OS: macOS
  • @graphql-codegen/...: 1.13.2
  • NodeJS: 12.16.1

Additional context

@ardatan
Copy link
Collaborator

ardatan commented Apr 7, 2020

Could you add commentDescriptions option like below and try again?

generates:
  ./gqltypes.ts:
    schema: 
        - ./schema.graphql:
              commentDescriptions: true
    plugins:
      - 'typescript'

@ardatan ardatan added waiting-for-answer Waiting for answer from author core Related to codegen core/cli labels Apr 7, 2020
@SimenB
Copy link
Contributor Author

SimenB commented Apr 7, 2020

That makes no difference

@ardatan
Copy link
Collaborator

ardatan commented Apr 7, 2020

In GraphQL Spec, comments with # are deprecated so you need to use """ descriptions instead.
You can see here;
graphql/graphql-js#927

Not sure if we change the behavior because supporting both descriptions and comments might break things. @dotansimha What do you think?

Maybe the following would work because we only removed commentDescriptions which can be added in those ways I already showed you.

generates:
  ./gqltypes.ts:
    schema: ./schema.graphql:
    plugins:
      - 'typescript'
    config:
       commentDescriptions: true

@SimenB
Copy link
Contributor Author

SimenB commented Apr 7, 2020

Aha, I didn't know that, thanks for the link! I'd still consider it worth pointing out in the changelog though. The only close to it is

Fix issues with missing descriptions and comments when schema is loaded from a url source (#3804 )

We've migrated to using """ now, so this is solved for us. But again, it should be noted in the changelog and not silently dropped

@ardatan ardatan closed this as completed Apr 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to codegen core/cli waiting-for-answer Waiting for answer from author
Projects
None yet
Development

No branches or pull requests

2 participants