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

schema parser does not support single line comments #201

Closed
7 tasks
bkcsfi opened this issue Apr 11, 2019 · 4 comments · Fixed by #212
Closed
7 tasks

schema parser does not support single line comments #201

bkcsfi opened this issue Apr 11, 2019 · 4 comments · Fixed by #212
Assignees
Labels
bug Something isn't working
Milestone

Comments

@bkcsfi
Copy link

bkcsfi commented Apr 11, 2019

Report a bug

Please provide

  • schema parser should accept files that contain single line comments
  • Tartiflette version: 0.7.3
  • Python version: 3.7.1
  • Executed in docker: No
  • GraphQL Schema & Query: e.g gist, pastebin or directly the query
type Bug {
    id: Int! # this is required
}
  • Is it a regression from a previous versions? unknown
  • Stack trace
Traceback (most recent call last):
  File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/bin/manifest-graphql", line 11, in <module>
    load_entry_point('entry-wizard', 'console_scripts', 'manifest-graphql')()
  File "/home/bkc/src/SFI/SFI.Projects.EntryWizard/entry_wizard/manifest_system/scripts/graphql_server.py", line 12, in main
    result = run()
  File "/home/bkc/src/SFI/SFI.Projects.EntryWizard/entry_wizard/graphql/server/app.py", line 59, in run
    engine = get_engine(schema_folder=schema_folder)
  File "/home/bkc/src/SFI/SFI.Projects.EntryWizard/entry_wizard/graphql/server/app.py", line 27, in get_engine
    "entry_wizard.graphql.resolvers.vendor",
  File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/tartiflette/engine.py", line 57, in __init__
    schema_name, custom_default_resolver, exclude_builtins_scalars
  File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 41, in bake
    schema = SchemaBakery._preheat(schema_name, exclude_builtins_scalars)
  File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/tartiflette/schema/bakery.py", line 21, in _preheat
    build_graphql_schema_from_sdl(sdl, schema=schema)
  File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 30, in build_graphql_schema_from_sdl
    sdl, parse_graphql_sdl_to_ast(sdl), schema=schema
  File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/tartiflette/sdl/builder.py", line 53, in parse_graphql_sdl_to_ast
    return gqlsdl(sdl)
  File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/lark/lark.py", line 223, in parse
    return self.parser.parse(text)
  File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/lark/parser_frontends.py", line 38, in parse
    return self.parser.parse(token_stream, *[sps] if sps is not NotImplemented else [])
  File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/lark/parsers/lalr_parser.py", line 82, in parse
    _action, arg = get_action('$END')
  File "/home/bkc/PythonEnvironments/SFI.Projects.EntryWizard/lib/python3.7/site-packages/lark/parsers/lalr_parser.py", line 49, in get_action
    raise UnexpectedToken(token, expected, state=state)  # TODO filter out rules from expected
lark.exceptions.UnexpectedToken: Unexpected token Token(BANG, '!') at line 1, column 3985.
Expected: SCHEMA, IDENT, TYPE, UNION, SCALAR, INTERFACE, MUTATION, RPAR, ENUM, STRING, QUERY, INPUT, LONG_STRING, TYPE_SYSTEM_DIRECTIVE_LOCATION, IMPLEMENTS, AT, EQUAL, DIRECTIVE, SUBSCRIPTION, RBRACE, EXTEND, ON, RSQB

see https://graphql.github.io/graphql-spec/June2018/#sec-Comments

perhaps this is a feature request?

@tsunammis
Copy link
Contributor

@bkcsfi Thank you for your bug report. We will analyze it during the next days.

Do not hesitate to join the Slack channel

@tsunammis tsunammis added the bug Something isn't working label Apr 11, 2019
@abusi abusi added this to the road-to-v1 milestone Apr 11, 2019
@abusi abusi self-assigned this Apr 16, 2019
@abusi
Copy link
Contributor

abusi commented Apr 16, 2019

@bkcsfi can you provide the complete sdl that is failing? your snippet seems to work fine on my setup ™️

@bkcsfi
Copy link
Author

bkcsfi commented Apr 17, 2019

sorry I was out of the office and could not reply in a timely manner. Sounds like you were able to recreate?

@abusi
Copy link
Contributor

abusi commented Apr 17, 2019

Yeah, it was due to a trick done to the result of the sdl loaded from a file (my first test was using a string in code, and was working). Before 0.8.6, when a SDL was loaded, it was "one lined" because our first version of the lark grammar was not complete and didn't support '\n' as expected. When that was resolved, we forget to "un-onelined" the loaded sdl.
Basicly when adding a # comment everything after was in the comment, regardless of the \n.
Now everything works fine.

Thanks for this bug report !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants