Skip to content

Add an option to fallback to comments if a description is not provided #459

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

Conversation

rideliner
Copy link
Contributor

Checklist

  • Pull requests follows the contribution guide
  • New or modified functionality is covered by tests

Description

The existing behavior is to always fallback to comments from the schema. This change would add a configuration option to SchemaParserOptions that would make it possible to ignore comments and exclusively use descriptions from the schema.

For example:

# Copyright 2020
# Authors: ...

type Query {
    hello: String!
}

This schema with the current behavior would result in the description being Copyright 2020\nAuthors: ....
With the commentsAsFallbackDescription option set as false, the description will be null.

@rideliner rideliner force-pushed the feature/comment-documentation branch from 9235282 to 1a613e0 Compare December 14, 2020 22:12
@rideliner rideliner requested a review from vojtapol December 14, 2020 22:55
@oryan-block
Copy link
Collaborator

@rideliner please resolve to conflict. We've migrated all tests to kotlin so you can leave it out. I can recreate your test after that.

The default behavior, to match existing behavior, is to fallback to
comments. Setting `commentsAsFallbackDescription` to false in the
`SchemaParserOptions` will result in comments not being used when a
description is not provided.
@rideliner rideliner force-pushed the feature/comment-documentation branch from 1a613e0 to 1235712 Compare April 21, 2021 21:03
when {
node.description != null -> node.description.content
!options.useCommentsForDescriptions -> null
node.comments.isNullOrEmpty() -> null

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two conditions both return null so you could just combine them into one.

Copy link
Collaborator

@oryan-block oryan-block left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 🚀

@oryan-block
Copy link
Collaborator

Closing this since we're unable to push/merge it as it is. Opened #564 with the same commits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants