Describe the bug
I noticed a few bizarre behaviors in the add plugin while upgrading from v1.1.3 to v1.3.1.
""" sometimes does not get emitted.typescript plugin i.e. import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql';To Reproduce the GraphQL output issue
Steps to reproduce the behavior: Use either of these codegen.yml config files.
overwrite: true
schema: 'schemas/*.graphql'
generates:
./foo-schema.graphql:
plugins:
- add: '"""'
- add: 'NOTE: THIS IS AN AUTO-GENERATED FILE. DO NOT MODIFY IT DIRECTLY.'
- add: 'Blah blah blah, more documentation.'
- add: '"""'
overwrite: true
schema: 'schemas/*.graphql'
generates:
./foo-schema.graphql:
plugins:
- add:
content:
- '"""'
- 'NOTE: THIS IS AN AUTO-GENERATED FILE. DO NOT MODIFY IT DIRECTLY.'
- 'Blah blah blah, more documentation.'
- '"""'
Expected behavior of the GraphQL output issue
Expected output:
"""
NOTE: THIS IS AN AUTO-GENERATED FILE. DO NOT MODIFY IT DIRECTLY.
Blah blah blah, more documentation.
"""
Actual output:
"""
NOTE: THIS IS AN AUTO-GENERATED FILE. DO NOT MODIFY IT DIRECTLY.
Blah blah blah, more documentation.
Note that the 2nd """ gets dropped here.
To Reproduce the TypeScript output issue
Steps to reproduce the behavior: Use the below codegen.yml config file.
overwrite: true
schema: 'schemas/*.graphql'
generates:
./graphql-schema.ts:
plugins:
- add:
content:
- '/**'
- ' * NOTE: THIS IS AN AUTO-GENERATED FILE. DO NOT MODIFY DIRECTLY.'
- ' */'
- typescript:
scalars:
DateTime: Date
- typescript-resolvers
Expected behavior of the TypeScript output issue
Expected output:
/**
* NOTE: THIS IS AN AUTO-GENERATED FILE. DO NOT MODIFY DIRECTLY.
*/
import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql';
...
Actual output:
/**
import { GraphQLResolveInfo, GraphQLScalarType, GraphQLScalarTypeConfig } from 'graphql';
* NOTE: THIS IS AN AUTO-GENERATED FILE. DO NOT MODIFY DIRECTLY.
*/
...
Hi @bnaoki , fixed it in: https://github.com/dotansimha/graphql-code-generator/pull/2169
For those waiting for the fix to be released, multiline string yaml is working fine:
definitions:
add: &top-comment
content: >
/**
* NOTE: THIS IS AN AUTO-GENERATED FILE. DO NOT MODIFY IT DIRECTLY.
*/
/* eslint-disable */
generates:
types/introspection-result.ts:
plugins:
- add: *top-comment
- 'fragment-matcher'
types/graphql.ts:
plugins:
- add: *top-comment
- 'typescript'
Fixed in 1.5.0 馃帀
Most helpful comment
For those waiting for the fix to be released, multiline string yaml is working fine: