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

Question: difference between comments and descriptions? #420

Closed
tonyghita opened this issue Mar 6, 2018 · 4 comments
Closed

Question: difference between comments and descriptions? #420

tonyghita opened this issue Mar 6, 2018 · 4 comments

Comments

@tonyghita
Copy link

Previous to merging descriptions into the specification, we used comments to document each field and type.

Does the introduction of descriptions deprecate the old functionality of comments? If so, what is the intended usage of comments? If not, what is the difference between comments and descriptions?

@IvanGoncharov
Copy link
Member

Does the introduction of descriptions deprecate the old functionality of comments?

@tonyghita Yes it does.

If so, what is the intended usage of comments?

type Person {
  """name of a person"""
  name: String
  #TODO: Add surname

  # FIXME: Commented due to crash
  # avatarUrl: String
}

So comments are completely ignored by GraphQL. They even skipped by parser so it makes them equivalent to whitespaces.

You can read about this change in more details here: graphql/graphql-js#927
If you have time and want to understand the motivation behind this change here is the relevant thread: #90 (comment)

@tonyghita
Copy link
Author

Thanks for the clarification and references @IvanGoncharov 👍

@marcospgp
Copy link

Time to update the docs with this info :) I can't see it anywhere here: https://graphql.org/learn/schema/#the-query-and-mutation-types

I seem to only be able to find it on unofficial resources. Cheers!

@lorensr
Copy link
Contributor

lorensr commented Jun 1, 2020

graphql-tools treats comments (#) as descriptions, in addition to " and """:

"""
comment 1
"""
type Query {
  # comment 2
  hello(
    "comment 3"
    name: String
  ): String
}

Comments can be written in Markdown. Spec section on descriptions: http://spec.graphql.org/draft/#sec-Descriptions

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

No branches or pull requests

4 participants