graphql-code-generator: schema-ast produces empty GraphQL docblock comments
Describe the bug
For some of my types, the ast-schema plugin generates docblocks comments that are empty:

Some types that do not have a description do not have those empty comments.
That wouldn’t be much annoying if they didn’t make the parser of the JS GraphQL WebStorm plugin fail the parsing (to workaround, I am now using commentDescriptions: true and everything is fine).
- My
codegen.ymlconfig file:
schema: "http://localhost:3001/graphql"
generates:
schema.graphql:
plugins:
- schema-ast
Expected behavior
I guess the generator does not put a comment block if it receives null for the comment from the introspection query. It should also do the same for empty strings.
Environment:
@graphql-codegen/...: everything in version1.17.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (7 by maintainers)
If the introspection query is returning an empty string instead of null for a description, then the issue is with the schema itself and not with codegen or graphql-tools. An empty string is not the same as “no description” and the expected behavior when printing a schema with such a description would be to print the provided value.
Example
I’m seeing the same thing as @Eddman described. I’ve tested this with two different GraphQL-implementations. One is based on https://github.com/99designs/gqlgen and one on https://graphene-python.org/.
Both produce the same thing when using
graphql@15.3.0, but it looks normal whengraphql@14.7.0is used.Edit:
I created a workaround for this issue with a hook on MacOS:
You could also use sed with something like:
sed -i '' -e ':a' -e 'N' -e '$!ba' -e 's/[ ]*""""""\n//g', but I think perl is more suitable for the job.