Skip to content

Schemas containing type or field description fail to be parsed correctly #124

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

Closed
almazik opened this issue Apr 9, 2020 · 4 comments
Closed
Labels
duplicate This issue or pull request already exists

Comments

@almazik
Copy link

almazik commented Apr 9, 2020

Description

The attempt to parse schema with description tokens results in exception

Steps to reproduce

var schema = Schema.For(@"""Root type for all queries""
type Query {
  ""Documentation for the field""
  name: String
}");

Expected result

Documentation should either be ignored or parsed into the corresponding fields

Actual result

Exception

GraphQLParser.Exceptions.GraphQLSyntaxErrorException: Syntax Error GraphQL (1:1) Unexpected String "Root type for all queries"
1: "Root type for all queries"
   ^
2: type Query {

  at at GraphQLParser.ParserContext.ParseDefinition()
  at at GraphQLParser.ParserContext.ParseDefinitionsIfNotEOF()
  at at GraphQLParser.ParserContext.ParseDocument()
  at at GraphQLParser.ParserContext.Parse()
  at at GraphQLParser.Parser.Parse(ISource source)
  at at GraphQL.Utilities.SchemaBuilder.Parse(String document)
  at at GraphQL.Utilities.SchemaBuilder.Build(String typeDefinitions)
  at at GraphQL.Types.Schema.For(String typeDefinitions, Action`1 configure)

Environment

.NET Core 3.1, graphql-dotnet 3.0.0-preview-1490

@sungam3r
Copy link
Member

sungam3r commented Apr 9, 2020

  1. Relates to Support for descriptions #33
  2. Did you intentionally use duplicate double quotes? http://spec.graphql.org/June2018/#sec-Descriptions talks about """ for block descriptions and " for single line descriptions.

@almazik
Copy link
Author

almazik commented Apr 10, 2020

  1. yes, agree, noticed parser issue once I started digging into the source code.
  2. duplicate quotes here are just C# escape symbols for verbatim strings (@"..."), the resulting string constant is

"Root type for all queries"
type Query {
"Documentation for the field"
name: String
}

@sungam3r
Copy link
Member

I can confirm this bug. Transferring issue into parser repo.

@sungam3r sungam3r transferred this issue from graphql-dotnet/graphql-dotnet Mar 11, 2021
@sungam3r
Copy link
Member

Closed as a duplicate of #33

@sungam3r sungam3r added the duplicate This issue or pull request already exists label Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants