graphql-go-tools icon indicating copy to clipboard operation
graphql-go-tools copied to clipboard

Graphql Parser doesn't handle comments?

Open sherodtaylor opened this issue 4 years ago • 3 comments

It seems like graphql parser doesn't like graphql comments in the schemas? This is using the federated proxy example.

build base schema: parse graphql document string: external: unexpected token - got: COMMENT want one of: [], locations:

remote schema

input UserInput {
    userID: Int
	# Some comment
	place: String
}

sherodtaylor avatar Jun 16 '21 20:06 sherodtaylor

Hey, you're right. Comments are not supported. You can use descriptions instead, these work fine.

jensneuse avatar Jun 17 '21 05:06 jensneuse

Is there no way to comment out graphql objects we've defined but don't want to be exposed because a description requires a key in the parser

This fails to parse because it needs a key. I feel like comments should just be ignored since they are supported still.

type User {
    """ Username """
    """ username: String! """
}

sherodtaylor avatar Jun 17 '21 14:06 sherodtaylor

Is there no way to comment out graphql objects we've defined but don't want to be exposed because a description requires a key in the parser

This fails to parse because it needs a key. I feel like comments should just be ignored since they are supported still.

type User {
    """ Username """
    """ username: String! """
}

I think it could help if you explain your use case a bit more. Filtering out fields from a schema is actually very trivial. This way, validation would fail if a client requests the field. That said, without further info on what you're trying to do I'm not sure I'm suggesting the right direction.

jensneuse avatar Jun 17 '21 16:06 jensneuse