Hotchocolate: Parser stuck on a schema file

Created on 25 Apr 2020  路  7Comments  路  Source: ChilliCream/hotchocolate

Describe the bug
The parser hangs indefinitely on a schema file.

To Reproduce
Run the following code:

    let HotChocolate x =
        let parser = HotChocolate.Language.Parser()
        let source = HotChocolate.Language.Source(x)
        parser.Parse(source)

on the following schema: http://pcarrier.ca/onegraph.graphql

Expected behavior
The program terminates.

Desktop (please complete the following information):

  • OS: Windows 10, up-to-date
  • Version 11.0.0-preview.127
bug 馃尪 hot chocolate

All 7 comments

I will have a look. Just as a side-note... this is our legacy parser interface. It is better to use Utf8GraphQLParser.Parse("string" or span)

btw ... thanks for reporting this.

The lexer works correctly but the parser seems to get stuck somewhere.

I have fixed the issue. The block string algorithm got stuck when the block string just consisted of one character and the algorithm tried to remove trailing lines from that.

However there are some escape issues in the schema.

For instance, the following block string:

Search for files with a query containing the "" character (e.g., "\authors")

    ```
    fullText contains '\\authors'
    ```

\\author is correct but \author will lead to an exception that the string is not correctly escaped.

Also there are strings like \_ which is also not a correct escape char.

http://spec.graphql.org/draft/#BlockStringCharacter

The spec says that a block string is either SourceCharacter OR \""" which means the standard escaping must be honoured.

http://spec.graphql.org/draft/#EscapedCharacter

If you correct these escapings the schema now parses correctly.

As mentioned you should use the newer API:
Utf8GraphQLParser.Parse(sourceText);

sourceText can be a Span<byte> or a string.

We will include the fix into preview.128

@michaelstaib Amazing, thanks for the prompt response and API guidance!

@pcarrier we also have a very active slack channel. if you fancy to join the community here here is the invitation link:
https://join.slack.com/t/hotchocolategraphql/shared_invite/enQtNTA4NjA0ODYwOTQ0LTViMzA2MTM4OWYwYjIxYzViYmM0YmZhYjdiNzBjOTg2ZmU1YmMwNDZiYjUyZWZlMzNiMTk1OWUxNWZhMzQwY2Q

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sergeyshaykhullin picture sergeyshaykhullin  路  3Comments

sgt picture sgt  路  4Comments

acelot picture acelot  路  4Comments

PascalSenn picture PascalSenn  路  5Comments

sfmskywalker picture sfmskywalker  路  3Comments